Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate react-native-gesture handler to version ^2 #912

Open
gax97 opened this issue Apr 12, 2022 · 23 comments · Fixed by #1126
Open

Migrate react-native-gesture handler to version ^2 #912

gax97 opened this issue Apr 12, 2022 · 23 comments · Fixed by #1126
Assignees
Labels
enhancement New feature or request v5
Milestone

Comments

@gax97
Copy link

gax97 commented Apr 12, 2022

Feature Request

There is a new version of react-native-gesture-handler with new API.

Why it is needed

There are warnings in the console:

 WARN  [react-native-gesture-handler] Seems like you're using an old API with gesture components, check out new Gestures system! 

Possible implementation

Add react-native-gesture-handler version ^2 and replace old API with new API

Code sample

/

@gax97 gax97 added the enhancement New feature or request label Apr 12, 2022
@tradebulls
Copy link

Even we are facing the same issues in our project. We are currently using "react-native-gesture-handler": "2.4.1" and it requires a piece of code to be commented in MainActivity. When removed, the backdrop press doesn't work in Android Bottom Sheet, works fine in IOS. Any help? @gorhom

@npjoge
Copy link

npjoge commented Apr 25, 2022

We are also facing same issue, works fine in iOS but issue with Android. Any help?

@arish-panjwani
Copy link

I am also facing the same issue...Any solutions yet?

@gorhom
Copy link
Owner

gorhom commented Apr 27, 2022

it is a warning not an issue. I got no plan to upgrade to GH2 for now.

@tradebulls
Copy link

tradebulls commented Apr 27, 2022

Agreed its a warning, however as per RNGesture Handler Version 2, they have deprecated RNGestureHandlerEnabledRootView.
Source Link - https://docs.swmansion.com/react-native-gesture-handler/docs/guides/migrating-off-rnghenabledroot/

Also, if you remove the piece of code from MainActivity, the backdrop of bottom sheet in Android is not clickable and the swipe gestures doesn't work as well.

@hirbod
Copy link

hirbod commented May 5, 2022

Just wrap you App with GestureHandlerRootView. I don't have any issues with the background.

@arish-panjwani
Copy link

@gorhom I am also facing the exact same issue as @tradebulls. I have tried @hirbod's solution but that didn't work.

@Gfr1992
Copy link

Gfr1992 commented Jun 4, 2022

After adding @gorhom/bottom-sheet and migrating to react-native-gesture 2.4.2 I have this error in android. DO you have any idea?

e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt: (5, 22): Unresolved reference: reanimated
e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt: (8, 35): Unresolved reference: ReanimatedModule
e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt: (12, 56): Not enough information to infer type variable T
e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt: (12, 72): Unresolved reference: ReanimatedModule
e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt: (14, 22): Unresolved reference: common
e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt: (25, 47): Unresolved reference: GestureHandlerStateManager
e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt: (410, 3): 'setGestureHandlerState' overrides nothing

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-gesture-handler:compileDebugKotlin'.

@tradebulls
Copy link

@hirbod Can you share some code snippet to help me?

@Gfr1992
Copy link

Gfr1992 commented Jun 7, 2022

After adding @gorhom/bottom-sheet and migrating to react-native-gesture 2.4.2 I have this error in android. DO you have any idea?

e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt: (5, 22): Unresolved reference: reanimated e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt: (8, 35): Unresolved reference: ReanimatedModule e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt: (12, 56): Not enough information to infer type variable T e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt: (12, 72): Unresolved reference: ReanimatedModule e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt: (14, 22): Unresolved reference: common e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt: (25, 47): Unresolved reference: GestureHandlerStateManager e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt: (410, 3): 'setGestureHandlerState' overrides nothing

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-gesture-handler:compileDebugKotlin'.

Solved. I noticed in package.json that the devDependency for react-native-gesture-handler is 1.10.3, so I downgrade to that version.

@jspizziri
Copy link

jspizziri commented Jun 16, 2022

@gorhom react-native-gesture-handler@v1.x hasn't been maintained for over a year. Moreover with newer versions of react-native I'm not 100% sure it's going to work. I haven't tested this, but I think the modifications to the MainActivity.java are incompatible with the newest RN version, and I think it's actually the reason for the migration off of RNGestureHandlerEnabledRootView . that was mentioned earlier.

I did some investigation and it looks like the breaking changes between 1.10.3 and the latest version only occurred in 2 releases:

Are you open to a contribution for v2 support?

@jspizziri
Copy link

jspizziri commented Jun 16, 2022

@hpelitebook745G2
Copy link

@Gfr1992 Did you mean you downgraded from react-native-gesture-handler: 2.4.2 to react-native-gesture-handler: 1.10.3 to fix that error?

@tradebulls
Copy link

Managed to fix the issue with @hirbod @jspizziri solution. I was wrapping GestureHandlerRootView in App.js. Tried adding it in index.js and it worked. Thanks guys for your help :)

@Gfr1992
Copy link

Gfr1992 commented Jul 22, 2022

@Gfr1992 Did you mean you downgraded from react-native-gesture-handler: 2.4.2 to react-native-gesture-handler: 1.10.3 to fix that error?

Yes

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@harveyconnor
Copy link

Is there a solution for this? We are getting crashes in production and it appears to be because we have multiple libraries that depend on different versions of gesture-handler.

Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: TypeError: this.InnerNativeModule.configureProps is not a function. (In 'this.InnerNativeModule.configureProps(n,t)', 'this.InnerNativeModule.configureProps' is undefined)', reason: 'Unhandled JS Exception: TypeError: this.InnerNativeModule.configureProps is not a function. (In 'this.InnerNativeModule.configureProps(n,t)', 'this.InnerNativeModule.configure..., stack:

@matthiasthomas
Copy link

Thank you @hirbod ! Your fix worked for me as well.

@tradebulls - Here's an excerpt from our app/index

const App = () => {
  const isLoadingComplete = useAppReadyToStart();

  if (!isLoadingComplete) return null;

  return (
    <GestureHandlerRootView style={{ flex: 1 }}>
      <ErrorBoundary>
        <QueryClientProvider client={queryClient}>
          <Provider store={store}>
            <ReduxNetworkProvider
              pingInterval={30000}
              pingServerUrl={`${config.API_HOST}/health/ping`}
            >
              <PersistGate loading={null} persistor={persistor}>
                <Main />
              </PersistGate>
            </ReduxNetworkProvider>
          </Provider>
        </QueryClientProvider>
      </ErrorBoundary>
    </GestureHandlerRootView>
  );
};

@github-actions
Copy link

github-actions bot commented Oct 3, 2022

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@gorhom gorhom added this to the Version 5 milestone Oct 3, 2022
@gorhom gorhom self-assigned this Oct 3, 2022
@gorhom gorhom pinned this issue Oct 3, 2022
@gorhom gorhom linked a pull request Oct 3, 2022 that will close this issue
@gorhom
Copy link
Owner

gorhom commented Oct 3, 2022

hi everyone, would you mind testing #1126, and report your findings :)

yarn add ssh://git@github.com:gorhom/react-native-bottom-sheet#feature/rewrite-gesture-handler-2

@eithe
Copy link

eithe commented Feb 2, 2023

Not sure if I should put this comment here or in #1125, but for other reasons we had to upgrade to gesture handler 2.x, and have been testing this on Android and iOS since December with much success.

We only have a somewhat simple BottomSheet, but it's used many places throughout the app, and it has scrolling views, left/right swipes for more content, dynamic snap points, and everything just works as expected.

With the positive test results we are going to production this week with your v5 branch.

If there is one wish I would have liked if you released an alpha version to npm of v5 so we could use that in our package.json instead of the github url, but no big deal :) Keep it up!

@edritech93
Copy link

Screenshot 2023-05-12 at 14 26 39

add kotlinVersion = '1.7.21' to gradle

After adding @gorhom/bottom-sheet and migrating to react-native-gesture 2.4.2 I have this error in android. DO you have any idea?

e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt: (5, 22): Unresolved reference: reanimated e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt: (8, 35): Unresolved reference: ReanimatedModule e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt: (12, 56): Not enough information to infer type variable T e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt: (12, 72): Unresolved reference: ReanimatedModule e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt: (14, 22): Unresolved reference: common e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt: (25, 47): Unresolved reference: GestureHandlerStateManager e: /Users/user_name/Projects/project_name/frontend/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt: (410, 3): 'setGestureHandlerState' overrides nothing

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-gesture-handler:compileDebugKotlin'.

@hungnd6282
Copy link

same me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v5
Projects
None yet
Development

Successfully merging a pull request may close this issue.