0
Follow
2
View

How can I open BottomSheetModal (@gorhom/bottom-sheet) in different component, using React-Native (Expo)

dinsam6 注册会员
2023-01-24 21:49

I found out to do this, incase anyone comes across this question, I'll post it here!

So what you have to do is pass the ref to the bottom sheet component. So in the Navbar component I created the ref for the bottom sheet, and then passed it into the bottom sheet.

Navbar:

// Create Ref
const userBottomSheetRef = useRef(null);

// Pass ref into the bottom sheet component
<omSheet ref={userBottomSheetRef} snapPoints={["30%"]}/>

Then inside the bottom sheet component you forward the ref using a react function, and then pass it in as normal:

 
    
      {children}