admin管理员组

文章数量:1418352

I want to use one bottom sheet and I am using useMemo, i tried forwardRef but it didn't work as I have to call same bottomsheet in almost 7-8 screen.

Tried to save ref in Zustand store globally using createRef or {current:null}. It works in one screen only but if I come back to the screen and want to reopen, the sheet ref becomes null.

const handleCloseModalPress = () => {
        bottomSheetModalRef?.current?.close();
    };

    const handleRevealPress = () => {
        handleCloseModalPress()
        navigation.navigate('MainSearch')}

Can someone help? I have tried many things but it's still not working

I want to use one bottom sheet and I am using useMemo, i tried forwardRef but it didn't work as I have to call same bottomsheet in almost 7-8 screen.

Tried to save ref in Zustand store globally using createRef or {current:null}. It works in one screen only but if I come back to the screen and want to reopen, the sheet ref becomes null.

const handleCloseModalPress = () => {
        bottomSheetModalRef?.current?.close();
    };

    const handleRevealPress = () => {
        handleCloseModalPress()
        navigation.navigate('MainSearch')}

Can someone help? I have tried many things but it's still not working

Share Improve this question edited Feb 3 at 16:18 Hamed Jimoh 1,4228 silver badges20 bronze badges asked Jan 29 at 17:15 ZeeshanZeeshan 18413 bronze badges 1
  • Have you tried the useBottomSheet hook? gorhom.dev/react-native-bottom-sheet/hooks#usebottomsheet – PhantomSpooks Commented Jan 30 at 0:55
Add a comment  | 

1 Answer 1

Reset to default 0

You can create two custom hooks, one for creating a new drawer and returning its ref, and the other one for using it via drawer's id.

本文标签: reactjsHow can I use one bottomsheet in many screen Gorhom bottomsheet React NativeStack Overflow