Skip to content

Incompatible with Reanimated 4 #176

@geertvansoest

Description

@geertvansoest

After upgrading to Reanimated 4 our app is breaking for both Android and iOS. This is caused by useAnimatedGestureHandler that no longer exists in Reanimated but it's used by this library. The console error is:

Warning: TypeError: 0, _reactNativeReanimated.useAnimatedGestureHandler is not a function (it is undefined)

More specific, the method is used in the onGestureEvent method:
https://github.com/birdwingo/react-native-instagram-stories/blob/main/src/components/Modal/index.tsx#L264-L348

The Reanimated docs mention the handler was deprecated in Reanimated 3 and is now removed:
https://docs.swmansion.com/react-native-reanimated/docs/guides/migration-from-3.x/#removed-useanimatedgesturehandler

I did some development using the new API (https://docs.swmansion.com/react-native-gesture-handler/docs/guides/upgrading-to-2). The available callbacks are different and the context is no longer available as a property, so the GestureContext should be maintained using a shared value. After some testing I have code working for us, but since we're not using all functions from this library I'm not sure we did tackle all potential issues.

Also, the outdated method is mentioned jest.setup.js but I didn't update it there already: https://github.com/birdwingo/react-native-instagram-stories/blob/main/jest.setup.js#L25

As a quick fix, I created a patch to fix issues for the Modal component:
@birdwingo+react-native-instagram-stories+1.3.18.patch

The warning I mentioned in #174 is still relevant.

Versions (library and dependencies):

@birdwingo/react-native-instagram-stories: 1.3.18
react: 19.1.0
react-native: 0.80.2
react-native-gesture-handler: 2.28.0
react-native-reanimated: 4.1.0
react-native-svg: 15.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions