react-native-bottom-sheet icon indicating copy to clipboard operation
react-native-bottom-sheet copied to clipboard

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

Open franamu opened this issue 2 years ago • 7 comments

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 avatar Oct 16 '24 12:10 franamu

I got it too. any solution?

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

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

Now working fine

ghost avatar Oct 17 '24 04:10 ghost

I have the same problem

fabricioferiozzi96 avatar Oct 17 '24 12:10 fabricioferiozzi96

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

conor909 avatar Oct 17 '24 18:10 conor909

i have updated the docs to include GestureHandlerRootView with every example

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

gorhom avatar Oct 20 '24 12:10 gorhom

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

Without GestureHandlerRootView (I need this behavior)

https://github.com/user-attachments/assets/f19ea66e-2a06-40e1-bf8c-d5bd7d9c92c1

With GestureHandlerRootView:

https://github.com/user-attachments/assets/1eb63ad0-9a11-42d8-b38a-477b01ceee24

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

franamu avatar Oct 21 '24 15:10 franamu

@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

bcliffor avatar Oct 23 '24 15:10 bcliffor

this is happening again. The GestureRootHandlerView is at the root. I am running RN 0.81.4 and the latest rnbottomsheet 5.2.6

procyphagenics avatar Oct 07 '25 09:10 procyphagenics