From bf51598c0d2782db6d1326e0e9cb983d34f44638 Mon Sep 17 00:00:00 2001 From: Arkadiusz Kubaczkowski Date: Thu, 22 Jan 2026 09:32:19 +0100 Subject: [PATCH] fix: race condition during fast open/close --- src/BottomSheetBackdrop.tsx | 7 +------ src/store/helpers.ts | 4 ++++ src/store/store.ts | 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/BottomSheetBackdrop.tsx b/src/BottomSheetBackdrop.tsx index a0a1bfc..788ce97 100644 --- a/src/BottomSheetBackdrop.tsx +++ b/src/BottomSheetBackdrop.tsx @@ -5,7 +5,6 @@ import Animated, { useAnimatedStyle, } from 'react-native-reanimated'; import { getAnimatedIndex } from './animatedRegistry'; -import { useSheetStatus } from './bottomSheet.store'; interface BottomSheetBackdropProps { sheetId: string; @@ -16,9 +15,7 @@ export function BottomSheetBackdrop({ sheetId, onPress, }: BottomSheetBackdropProps) { - const status = useSheetStatus(sheetId); const animatedIndex = getAnimatedIndex(sheetId); - const isInteractive = status === 'open'; const animatedStyle = useAnimatedStyle(() => { const opacity = interpolate( @@ -35,9 +32,7 @@ export function BottomSheetBackdrop({ { - if (isInteractive) { - onPress?.(); - } + onPress?.(); }} > , id: string, diff --git a/src/store/store.ts b/src/store/store.ts index fbce896..4076235 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -7,6 +7,7 @@ import { getTopSheetId, isActivatableKeepMounted, isHidden, + isOpening, removeFromStack, updateSheet, } from './helpers'; @@ -66,7 +67,7 @@ export const useBottomSheetStore = create( startClosing: (id) => set((state) => { const sheet = state.sheetsById[id]; - if (!sheet || isHidden(sheet)) return state; + if (!sheet || isHidden(sheet) || isOpening(sheet)) return state; let updatedSheetsById = updateSheet(state.sheetsById, id, { status: 'closing',