react-native-bottom-sheet: [v5] Bottom sheet is not longer opening
Bug
Environment info
| Library | Version |
|---|---|
| @gorhom/bottom-sheet | 5.0.0-alpha.7 |
| react-native | 0.72.10 |
| react-native-reanimated | 3.3.0 |
| react-native-gesture-handler | 2.12.0 |
Steps To Reproduce
- just using this version “@gorhom/bottom-sheet”: “4.4.7” it works perfectly.
Describe what you expected to happen:
I expect it to be opened.
Reproducible sample code
That’s the code i have and whenever i want to open the bottom sheet it does not even open it.
import { View } from 'react-native'
import { BottomSheetBackdrop, BottomSheetModal } from '@gorhom/bottom-sheet'
import React, { RefObject, useCallback, useMemo } from 'react'
import CheatSheetContent from './CheatSheetContent'
import { styles } from './CheatSheet.styles'
type CheatSheetProps = {
bottomSheetModalRef: RefObject<BottomSheetModal>
}
const CheatSheet = ({ bottomSheetModalRef }: CheatSheetProps) => {
const renderBackdrop = useCallback(
(props: React.ComponentProps<typeof BottomSheetBackdrop>) => (
<BottomSheetBackdrop {...props} disappearsOnIndex={-1} appearsOnIndex={0} />
),
[]
)
const snapPoints = useMemo(() => ['85%'], [])
return (
<View>
<BottomSheetModal
ref={bottomSheetModalRef}
index={0}
snapPoints={snapPoints}
backdropComponent={renderBackdrop}
detached={false}
handleStyle={styles.bottomSheetHandleStyle}
handleIndicatorStyle={styles.bottomSheetIndicatorStyle}
keyboardBlurBehavior="restore"
>
<CheatSheetContent />
</BottomSheetModal>
</View>
)
}
And open it like this.
const bottomSheetModalRef = useRef<BottomSheetModal>(null)
const openBottomModal = useCallback(() => {
bottomSheetModalRef.current?.present()
}, [])
const closeBottomModal = useCallback(() => {
bottomSheetModalRef.current?.close()
}, [bottomSheetModalRef])
<CheatSheet bottomSheetModalRef={bottomSheetModalRef} />
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 4
- Comments: 27 (2 by maintainers)
@Monir-Shembesh you need to replace the children of the bottom sheet from
ViewtoBottomSheetView, in order to get it workingWhen I add enableDynamicSizing={false} it works
wrap your BottomSheet children in a
BottomSheetViewinstead ofViewIt is working correctly if I use a normal
Viewas a child withenableDynamicSizingprop set tofalse. I believe thatBottomSheetViewis mainly used for dynamic resizing correct? @gorhom