Skip to content

[v4] | [v2] snapToPosition opening bottomsheet to maximum screen height and snapToIndex not working #1294

Closed
@anis-18

Description

@anis-18

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

  1. create react native app
  2. use bottomsheet from library
  3. use snapToIndex and snapToPosition inside useeffect or useLayoutEffect

Describe what you expected to happen:

  1. open bottomsheet with correct index provided
  2. 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]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions