Skip to content

[V4] Dynamic Snap points not working with React Navigation #601

Open
@thebiltheory

Description

@thebiltheory

Bug

Environment info

Library Version
@gorhom/bottom-sheet 4.0.0-alpha.30
react-native expo sdk-42.0.0
react-native-reanimated 2.2.0
react-native-gesture-handler 1.10.2
react-native-gesture-handler 1.10.2
@react-navigation/drawer 6.1.0
@react-navigation/native 6.0.2
@react-navigation/native-stack 6.1.0
@react-navigation/stack 6.0.3

Steps To Reproduce

Example Snack: https://snack.expo.dev/@thebiltheory/bottom-sheet-v4-with-react-navigation

  1. Implement dynamic snap points example
  2. Implement a navigator

Describe what you expected to happen:

  1. For the bottom sheet to dynamically take an appropriate height based on the content in each screen.
  2. For the bottom sheet to have a minimum height while a "loader" is being shown

Reproducible sample code

Example Snack: https://snack.expo.dev/@thebiltheory/bottom-sheet-v4-with-react-navigation

  const {
    animatedHandleHeight,
    animatedSnapPoints,
    animatedContentHeight,
    handleContentLayout,
  } = useBottomSheetDynamicSnapPoints(["CONTENT_HEIGHT"]);


<NativeViewGestureHandler disallowInterruption={true}>
      <View flex={1}>
        <BottomSheetModal
          name="Select"
          ref={newBookingModal.ref}
          onDismiss={resetCarForm}
          snapPoints={animatedSnapPoints}
          handleHeight={animatedHandleHeight}
          contentHeight={animatedContentHeight}
          enablePanDownToClose={true}
          keyboardBehavior="interactive"
          android_keyboardInputMode="adjustPan"
        >
          <BottomSheetScrollView
            onLayout={handleContentLayout}
            style={{
              flex: 1,
              backgroundColor: "red",
            }}
          >
            <NewBookingNavigator />
          </BottomSheetScrollView>
        </BottomSheetModal>
      </View>
    </NativeViewGestureHandler>

NewBookingNavigator.ts

 <NavigationContainer independent={true}>
      <Stack.Navigator
        screenOptions={screenOptions}
        initialRouteName="ScreenOne"
      >
        <Stack.Screen
          name="ScreenOne"
          options={{ title: "Screen One", headerShown: false }}
          component={ScreenOne}
        />
        <Stack.Screen
          name="ScreenTwo"
          options={{ title: "Screen Two", headerShown: false }}
          component={ScreenTwo}
        />
        ...
      </Stack.Navigator>
    </NavigationContainer>

Originally posted by @thebiltheory in #427 (comment)

Metadata

Metadata

Assignees

Labels

v4Written in Reanimated v2

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions