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

  1. 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)

Most upvoted comments

@Monir-Shembesh you need to replace the children of the bottom sheet from View to BottomSheetView, in order to get it working

When I add enableDynamicSizing={false} it works

wrap your BottomSheet children in a BottomSheetView instead of View

@Monir-Shembesh you need to replace the children of the bottom sheet from View to BottomSheetView, in order to get it working

It is working correctly if I use a normal View as a child with enableDynamicSizing prop set to false. I believe that BottomSheetView is mainly used for dynamic resizing correct? @gorhom