react-native-scroll-bottom-sheet icon indicating copy to clipboard operation
react-native-scroll-bottom-sheet copied to clipboard

snapTo() not working with RN 0.63

Open mike-hamilton opened this issue 4 years ago • 2 comments

Current Behavior

I just upgraded my project from RN 0.62.2 to 0.63 and I noticed the snapTo function appears to not be working. The code below worked fine on 0.62.2 (and the console.log shows up in 0.63, so the useEffect() is running..)

  const bottomSheetRef = useRef();

  // Close the bottom sheet
  useEffect(() => {
    if (!bottomSheetIsOpen) {
      console.log('closing BS!');
      bottomSheetRef.current.snapTo(1);
    }
  }, [bottomSheetIsOpen]);

Expected Behavior

The bottom sheet should snap to provided index

Your Environment

package version
react-native-scroll-bottom-sheet 0.6.2
react-native 0.63.0
react-native-gesture-handler 1.6.1
react-native-reanimated 1.9.0

mike-hamilton avatar Jul 09 '20 19:07 mike-hamilton

I got it working by wrapping it into a small timeout

happyfloat avatar Aug 27 '20 20:08 happyfloat

I think the issue is not the snapTo itself, but rather something to do with component being re-rendered. If you called snapTo from some button directly (and not listening to state changes, which cause re-render), it would work.

Kristonitas avatar Nov 23 '20 17:11 Kristonitas