Closed
Description
Bug
snapToPosition method is opening bottomsheet in maximum screen height and snapToIndex is not working when used in useEffect
Environment info
Library | Version |
---|---|
@gorhom/bottom-sheet | ^4 |
react-native | 0.70.5 |
react-native-reanimated | 2.13.0 |
react-native-gesture-handler | 2.6.1 |
Steps To Reproduce
- create react native app
- use bottomsheet from library
- use snapToIndex and snapToPosition inside useeffect or useLayoutEffect
Describe what you expected to happen:
- open bottomsheet with correct index provided
- open bottomsheet with correct prosition provided
Reproducible sample code
const snapPoints = React.useMemo(
() => ['10%', '25%', '45%', '65%', '95%'],
[],
);
React.useEffect(() => {
sheetRef.current?.snapToPosition(400); // this opens bottomsheet to maximum screen height
// or this
// sheetRef.current?.snapToIndex(3); // this is not working at all
}, [sheetRef.current , loaded]);