Skip to content

Commit

Permalink
preventing multiple calls for onClose
Browse files Browse the repository at this point in the history
currently `_providedOnClose` gets called potentially multiple times as this reanimated hook may (and likely will) run multiple times - I believe it should be called only once when changing `_animatedIndex` to `-1` only
  • Loading branch information
wawrow authored Dec 6, 2024
1 parent 7bfe7ae commit 3845bb8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/bottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1836,7 +1836,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
/**
* if index is `-1` than we fire the `onClose` callback.
*/
if (_animatedIndex === -1 && _providedOnClose) {
if (_animatedIndex === -1 && _animatedIndex !== animatedCurrentIndex.value && _providedOnClose) {
if (__DEV__) {
runOnJS(print)({
component: BottomSheet.name,
Expand Down

0 comments on commit 3845bb8

Please sign in to comment.