Open augustebr opened 2 months ago
The bottom-sheet is not dismissed when dismiss() is called soon after present(). This happens when these two are called in quick succession. The code in the example demonstrates the issue and here's also a short video of that code in action.
dismiss()
present()
https://github.com/user-attachments/assets/18991be9-47e5-4278-a900-2603d82605a9
npm install
npx expo start
Describe what you expected to happen:
import React, { useMemo, useState, useEffect } from 'react'; import { View, Text, StyleSheet, Button } from 'react-native'; import { GestureHandlerRootView } from 'react-native-gesture-handler'; import { BottomSheetModal, BottomSheetModalProvider } from '@gorhom/bottom-sheet'; export default function App() { const [isOpen, setIsOpen] = useState(false); const ref = React.useRef<BottomSheetModal>(null); const snapPoints = useMemo(() => ['25%', '50%'], []); useEffect(() => { if (isOpen) { ref.current?.present(); } else { ref.current?.dismiss(); } }, [isOpen]); const toggleSheet = () => { setIsOpen(prevState => !prevState); }; return ( <GestureHandlerRootView style={styles.container}> <BottomSheetModalProvider> <View style={styles.container}> <Button title={isOpen ? "Close Sheet" : "Open Sheet"} onPress={toggleSheet} /> <BottomSheetModal ref={ref} index={1} snapPoints={snapPoints} enablePanDownToClose={true} onDismiss={() => setIsOpen(false)} > <View style={styles.contentContainer}> <Text>Bottom Sheet Modal Content</Text> </View> </BottomSheetModal> </View> </BottomSheetModalProvider> </GestureHandlerRootView> ); } const styles = StyleSheet.create({ container: { flex: 1, padding: 24, backgroundColor: 'black', }, contentContainer: { flex: 1, alignItems: 'center', }, });
same problem here
this should be fixed with the next alpha releases of v5
v5
https://github.com/user-attachments/assets/88a30cef-688e-47d8-98a0-122a2454ceb5
@gorhom when are you planning to release alpha?
Bug
The bottom-sheet is not dismissed when
dismiss()
is called soon afterpresent()
. This happens when these two are called in quick succession. The code in the example demonstrates the issue and here's also a short video of that code in action.https://github.com/user-attachments/assets/18991be9-47e5-4278-a900-2603d82605a9
Environment info
Steps To Reproduce
npm install
npx expo start
Describe what you expected to happen:
Reproducible sample code