gorhom / react-native-bottom-sheet

A performant interactive bottom sheet with fully configurable options 🚀
https://gorhom.dev/react-native-bottom-sheet/
MIT License
6.86k stars 750 forks source link

[v4] [v5] | [v2] ‘BottomSheetModalInternalContext’ cannot be null error in expo-router #1506

Closed crstnmac closed 1 year ago

crstnmac commented 1 year ago

Bug

We have a open source library which uses the bottomsheet ,when we use the component inside a expo-router project we get

  ‘BottomSheetModalInternalContext’ cannot be null 

even after BottomSheetModalProvider is wrapped in the _layout.tsx file of the root

Environment info

Library Version
@gorhom/bottom-sheet 5.0.0.alpha-3
react-native 0.72.4
react-native-reanimated 3.3.0
react-native-gesture-handler 2.12.0

Steps To Reproduce

  1. Install @gorhom/react-native-bottom-sheet in a expo-router project and also add @adaptui/react-native-tailwind@1.0.0-alpha.13 2.Use the select component as described here
  2. Run the app

Describe what you expected to happen:

1.Expected to open a sheet with options

Reproducible sample code

Reproducable code:-

https://github.com/crstnmac/remember-me/tree/select-bug

github-actions[bot] commented 1 year ago

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.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 5 days with no activity.

sutyum commented 8 months ago

Did this work out? Does Expo Router V3 help?

naytun commented 5 months ago

You just need to wrap in <BottomSheetModalProvider> as follow:

         <BottomSheetModalProvider>
            <BottomSheetModal
               ref={bottomSheetModalRef}
               index={0}
               snapPoints={snapPoints}
            >
               <ScrollView contentContainerStyle={...}>
                  ...
               </ScrollView>
            </BottomSheetModal>
         </BottomSheetModalProvider>