React-native-reanimated: PinchGestureHandler is not supported?

Created on 28 Aug 2020  路  7Comments  路  Source: software-mansion/react-native-reanimated

Description

PinchGestureHandler is not supported?

Code

const Test: FunctionComponent = () => {
  const onGestureEvent = useAnimatedGestureHandler({
    onActive: () => {
      console.info('active');
    },
  });

  return (
    <PinchGestureHandler onGestureEvent={onGestureEvent}>
      <Animated.View >
      </Animated.View>
    </PinchGestureHandler>
  );
};

typescript error

No overload matches this call.
  Overload 1 of 2, '(props: Readonly<PinchGestureHandlerProperties>): PinchGestureHandler', gave the following error.
    Type 'OnGestureEvent' is not assignable to type '(event: PinchGestureHandlerGestureEvent) => void'.
      Types of parameters 'event' and 'event' are incompatible.
        Type 'PinchGestureHandlerGestureEvent' is not assignable to type 'PanGestureHandlerGestureEvent'.
          Types of property 'nativeEvent' are incompatible.
            Type 'GestureHandlerGestureEventNativeEvent & PinchGestureHandlerEventExtra' is not assignable to type 'NativeEvent'.
              Type 'GestureHandlerGestureEventNativeEvent & PinchGestureHandlerEventExtra' is missing the following properties from type 'PanGestureHandlerEventExtra': x, y, absoluteX, absoluteY, and 4 more.
  Overload 2 of 2, '(props: PinchGestureHandlerProperties, context?: any): PinchGestureHandler', gave the following error.
    Type 'OnGestureEvent' is not assignable to type '(event: PinchGestureHandlerGestureEvent) => void'.

Package versions

"react": "16.13.1",
"react-native": "0.63.2",
"react-native-gesture-handler": "1.7.0",
"react-native-reanimated": "2.0.0-alpha.5",

鉂換uestion 馃彔 Reanimated2

All 7 comments

You should pass it as a generic parameter of useAnimatedGestureHandler. Here you can find an example https://www.github.com/terrysahaidak/reanimated-gallery/tree/master/src%2FImageTransformer.tsx

But in example you use your custom useAnimatedGestureHandler and not default useAnimatedGestureHandler from library. It is not suported in library?

My custom one just has additional callbacks but shares the same typings so yes, it will work the same way.

I am sorry but I do not understand it, in generic parameter of useAnimatedGestureHandler I can set only context type

  export function useAnimatedGestureHandler<TContext extends Context>(
      handlers: GestureHandlers<TContext>
    ): OnGestureEvent;

Sorry, you're right. You can use my version as a workaround for now, but that's something we should address for sure.

Will fix it later.

Hi @Risbot, just created PR which fixes it. Would be cool if you test it.

Thank you. I will try it when i get any free time

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bjartebore picture bjartebore  路  3Comments

dinhmai74 picture dinhmai74  路  3Comments

wasim-abuzaher picture wasim-abuzaher  路  3Comments

sa8ab picture sa8ab  路  3Comments

afctemka picture afctemka  路  3Comments