Reputation: 180
I am new to typescript. The linter has been able to Quick fix for me but the following section of code offers no quick actions available for the linter to fix with:
The problem message is "Type 'void' is not assignable to type 'CompositeAnimation'.ts(2322)"
Animated.parallel([
Animated.spring(this.position, {
toValue: ({ x: 0, y: 0 }),
}).start(),
Animated.spring(this.swipeCardPosition, {
toValue: ({ x: 0, y: -SCREEN_HEIGHT }),
}).start(),
]).start();
Upvotes: 2
Views: 1335
Reputation: 266
I think the problem is that the Animated.parallel() method accepts an array of composite animation objects. Animate.spring() returns a composite animation object, but you call the start() method on both of these animations, which has a return type of void.
Try the following code, I think it should work accordingly:
Animated.parallel([
Animated.spring(this.position, {
toValue: ({ x: 0, y: 0 }),
}),
Animated.spring(this.swipeCardPosition, {
toValue: ({ x: 0, y: -SCREEN_HEIGHT }),
}),
]).start();
Notice that I didn't start the spring animations, I just start the "root" animation which contains the two spring animations.
I hope it will help you.
Upvotes: 6