reactjsreact-nativebottom-sheetreact-native-scrollview

Scroll content inside @gorhom/bottom-sheet - React Native


I am trying to implement a Comments Section inside a Bottom Sheet (@gorhom/bottom-sheet). The problem I am facing is that when I try to scroll the content (comments), it doesn't work, and instead the bottom sheet collapses.

Here is what I tried :

      <BottomSheet
        ref={bottomSheetRef}
        index={0}
        snapPoints={snapPoints}
        onChange={handleSheetChanges}
      >
        <View style={styles.contentContainer}>
          <Text>{comments} Comments</Text>
          <Comments />
        </View>
      </BottomSheet>

Solution

  • Instead of View please use BottomSheetScrollView from @gorhom/bottom-sheet or use ScrollView from react-native-gesture-handler.

    <BottomSheet
        ref={bottomSheetRef}
        index={0}
        snapPoints={snapPoints}
        onChange={handleSheetChanges}
      >
        <BottomSheetScrollView style={styles.contentContainer}>
          <Text>{comments} Comments</Text>
          <Comments />
        </BottomSheetScrollView>
      </BottomSheet>