Open mstaniewski opened 10 months ago
I tried to reproduce this not able to reproduce @mstaniewski please share details.if possible share along with snack example
Same issues with the bottom sheet cannot be get the correct height without set any snapPoints.
export default function Test() {
const [item, setItem] = useState<String>();
const bottomSheetRef = useRef<BottomSheet>(null);
useEffect(() => {
new Promise((resolve) => {
resolve(setItem("Test"));
}).then(() => bottomSheetRef.current?.expand());
});
return (
<BottomSheet
ref={bottomSheetRef}
snapPoints={[]}
enablePanDownToClose
enableDynamicSizing
animateOnMount
index={-1}
>
<BottomSheetView>{item && <Text>Testing</Text>}</BottomSheetView>
</BottomSheet>
);
}
Make sure to wrap your app/screen in BottomSheetModalProvider
and provide a valid (snap point) index (e.g. 0)
The app/screen is in BottomSheetModalProvider
and updates the method to bottomSheetRef.current?.snapToIndex(0)
. Still getting the same result, is there any misunderstanding on my part?
I also encountered a problem. any other ideas?
https://github.com/gorhom/react-native-bottom-sheet/issues/1573
You can find a workaround here
I found a hacky workaround adding a minHeight
or padding
to BottomSheetView
.
<BottomSheetBase
ref={bottomSheetRef}
backdropComponent={BackdropView}
footerComponent={Footer}
handleComponent={handleComponent}
enablePanDownToClose
onClose={onClose}
enableDynamicSizing
>
<BottomSheetView
style={{ minHeight: 10 }} // <----- It works 🤷🏽♂️
>
Still this is super hacky and should be solved 👍🏽
if you give the BottomSheetView and a wrapping View inside padding the enableDynamicSizing works. note index={0} and enableDynamicSizing={true} needs to be in BottomSheetModal also if BottomSheetView is given any other padding like padding-bottom etc it does not work.
P.S: no idea if this is a proper solution or not, it worked for me so i thought i would share it.
` <BottomSheetModal index={0} enableDynamicSizing={true}
<BottomSheetView style={{padding: '40px'> <View style={{padding-bottom: '80px'> // all the code in the modal should be placed inside this view `
if you give the BottomSheetView and a wrapping View inside padding the enableDynamicSizing works. note index={0} and enableDynamicSizing={true} needs to be in BottomSheetModal also if BottomSheetView is given any other padding like padding-bottom etc it does not work.
P.S: no idea if this is a proper solution or not, it worked for me so i thought i would share it.
` <BottomSheetModal index={0} enableDynamicSizing={true}
<BottomSheetView style={{padding: '40px'> <View style={{padding-bottom: '80px'> // all the code in the modal should be placed inside this view `
Thats the only thing which worked for me. Thank you for your solution!!
Bug
I need bottom sheet modals to adjust to its content height. I have found
enableDynamicSizing
prop in documentation and a pull request regarding dynamic sizing: https://github.com/gorhom/react-native-bottom-sheet/pull/1513I have checked the example on how to use it here:
https://github.com/gorhom/react-native-bottom-sheet/pull/1513/files#diff-3f9ab4750993038cd43946db156ced8ad2138a75159f43862a3906e0747af3e7R52
Unfortunately bottom sheet height is not calculated properly. First modal appears good because it has snap points set. Second is displaying like content would be of height 0
https://github.com/gorhom/react-native-bottom-sheet/assets/11744682/7e8ffb53-37d3-4310-8d8e-c7b290680254
Environment info
"@gorhom/bottom-sheet": "^4.6.0", "react-native": "^0.73.2",
Steps To Reproduce
Import BottomSheetModal from module, use it as presented in example and docs. Content height is not calculated
Describe what you expected to happen:
Modal appears with height adjusted to its content
Reproducible sample code