stanleyugwu / react-native-bottom-sheet

The tiny 📦, smart 😎, and flexible 🎗 bottom sheet your app craves
https://github.com/stanleyugwu/react-native-bottom-sheet#readme
MIT License
311 stars 12 forks source link

example of Extend sheet height when its content is scrolled #26

Closed Madeean closed 3 months ago

Madeean commented 3 months ago

hi, could you please tell me the code example of Extend sheet height when its content is scrolled?

stanleyugwu commented 3 months ago

Something like below should work

export default function App() {
  const sheetRef = React.useRef<BottomSheetMethods>(null);
  const [dynamicHeight, setDynamicHeight] = React.useState(200)

  return (
    <View style={styles.container}>
      <BottomSheet ref={sheetRef} height={dynamicHeight}>
        <ScrollView onScroll={() => setDynamicHeight(500)}>
        <Text>HELLO</Text>
        </ScrollView>
      </BottomSheet>
    </View>
  );
}

The height prop is somewhat alive lol, so any changes to it would cause the sheet to re-render and adjust it's height accordingly