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

[Bug]: [v5]GestureDetector must be used as a descendant of GestureHandlerRootView #1979

Closed
franamu opened this issue Oct 16, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@franamu
Copy link

franamu commented Oct 16, 2024

Version

v5

Reanimated Version

v3

Gesture Handler Version

v2

Platforms

iOS, Android

What happened?

Error: GestureDetector must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.

Plataform: IOS, Android

On Web works fine

Reproduction steps

  • When trigger the event to show de component BottomSheet crash the app.

Reproduction sample

https://snack.expo.dev/@franamu/bottom-sheet---issue-reproduction-template

Relevant log output

GestureDetector must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.

Captura de pantalla 2024-10-16 a la(s) 9 37 41 a  m

On web works fine:

Captura de pantalla 2024-10-16 a la(s) 2 28 29 p  m
@franamu franamu added the bug Something isn't working label Oct 16, 2024
@franamu franamu changed the title [Bug]: GestureDetector must be used as a descendant of GestureHandlerRootView [Bug]: [v5]GestureDetector must be used as a descendant of GestureHandlerRootView Oct 16, 2024
@rajangargsmartdata
Copy link

rajangargsmartdata commented Oct 17, 2024

I got it too. any solution?

Update:- I missed one step to wrap app with these

<GestureHandlerRootView>
       <BottomSheetModalProvider>
{app}
       </BottomSheetModalProvider>
</GestureHandlerRootView>

Now working fine

@fabricioferiozzi96
Copy link

I have the same problem

@conor909
Copy link

conor909 commented Oct 17, 2024

@fabricioferiozzi96 Your <BottomSheetProvider> is not a child of <GestureHandlerRootView style={{ flex: 1 }}>

@gorhom
Copy link
Owner

gorhom commented Oct 20, 2024

i have updated the docs to include GestureHandlerRootView with every example

https://gorhom.dev/react-native-bottom-sheet/usage

@gorhom gorhom closed this as completed Oct 20, 2024
@franamu
Copy link
Author

franamu commented Oct 21, 2024

@gorhom @rajangargsmartdata thank you! works fine in all plataforms, but the behavior is different nonetheless.

Without GestureHandlerRootView
(I need this behavior)

Grabacion.de.pantalla.2024-10-21.a.la.s.12.07.51.p.m.mov

With GestureHandlerRootView:

Grabacion.de.pantalla.2024-10-21.a.la.s.12.04.25.p.m.mov

If I change the color, it's the same because the GestureHandlerRootView container doesn't leave until bottomSheetRef.current?.close(); event finishes.

@bcliffor
Copy link

@gorhom thanks for all the work on the library!

I just stumbled across this error and I believe it was because in the modal usage example the order of the BottomSheetModalProvider and GestureHandlerRootView is swapped. Works fine once I corrected that. I wanted to point that out incase the documentation does indeed need to be updated to remove confusion.

https://gorhom.dev/react-native-bottom-sheet/modal/usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants