I’m using the popular package @gorhom/bottom-sheet
for a bottom sheet in React Native documented here. However, I am getting the above error when trying to present the modal.
The above error suggests that I must have a PanGestureHandler
as a descendant of the GestureHandlerRootView
however, this also crashes the app.
APP.JS:
return (
<BottomSheetModalProvider>
<NavigationContainer>
{user ? <AuthorizedLayout /> : <UnauthorizedLayout />}
</NavigationContainer>
</BottomSheetModalProvider>
);
MY MODAL SCREEN
return (
<>
{loading ? (
<ExploreSkeleton />
) : (
<>
<ExploreHeader
userData={userData}
presentCityModal={presentCityModal}
/>
<FlatList
data={venues}
ListHeaderComponent={listHeaderComponent}
renderItem={renderItem}
ListFooterComponent={listFooterComponent}
contentContainerStyle={styles.contentContainerStyle}
onEndReached={getMoreVenues}
onEndReachedThreshold={0.5}
/>
<GestureHandlerRootView>
<BottomSheetModal snapPoints={snapPoints} ref={bottomSheetModalRef}>
<View>
<Text>TESTING MODAL</Text>
</View>
</BottomSheetModal>
</GestureHandlerRootView>
</>
)}
</>
);
I HAVE TRIED:
<GestureHandlerRootView>
<PanGestureHandler>
<BottomSheetModal
snapPoints={snapPoints}
ref={bottomSheetModalRef}>
<View>
<Text>TESTING MODAL</Text>
</View>
</BottomSheetModal>
</PanGestureHandler>
</GestureHandlerRootView>
But this gives me;
Argument appears to not be a ReactComponent.
2
Answers
Found the answer here. You need to have the
<GestureHandlerRootView>
before the<BottomSheetModalProvider>
Code below;
APP.JS
You should add
GestureHandlerRootView
toAPP.JS
, not just only wrapPanGestureHandler
: