React-native-gesture-handler: Using Animated.event with TapGestureHandler onHandlerStateChange doesn't work

Created on 30 Oct 2019  路  5Comments  路  Source: software-mansion/react-native-gesture-handler

This is usage with react-native-reanimated.

I get this error:

Expected `onGestureHandlerStateChange` listener to be a function, instead got a value of `object` type.

Example:

const tapState = new Animated.Value(0);
const tapStateEvent = Animated.event([{ nativeEvent: { state: tapState } }]);
// ...
<TapGestureHandler onHandlerStateChange={tapStateEvent}>{...}</TapGestureHandler>

Most helpful comment

For future reference I was able to solve my problem by having the GestureHandler's immediate child changed to a reanimated Animated.View

All 5 comments

I'll plus one here. Getting the same thing on PinchGestureHandler

For future reference I was able to solve my problem by having the GestureHandler's immediate child changed to a reanimated Animated.View

Thank you !

@mnmaraes time saver !

In the event that using Animated.View does not fix this issue, double-check your imports. I was mistakenly importing Animated from react-native instead of react-native-reanimated.

Was this page helpful?
0 / 5 - 0 ratings