stipsan / react-spring-bottom-sheet

Accessible ♿️, Delightful ✨, & Fast 🚀
https://react-spring.bottom-sheet.dev/
MIT License
967 stars 133 forks source link

BottomSheet resets to previous snap point when trying to track height #254

Open Tasemu opened 1 year ago

Tasemu commented 1 year ago

We have an issue where we need to track whether our bottom sheet is maximised or minimised in our app. The sheet is always open but can be either full screen or minimal at the bottom of the screen. We are trying to use onSpringEnd to set a local state but when we do this, the re-render seems to conflict with the sheet and causes it to jump back to its previous snap point?

const [height, setHeight] = useState(0);
 <Sheet
          open
          {....otherProps}
          ref={sheetRef}
          onSpringEnd=(() => { setHeight(sheetRef.height) })
          />
        }
      >