react-native-bottom-sheet
react-native-bottom-sheet copied to clipboard
Fix Memory leak in BottomSheetBackdrop
Motivation
- Fix Memory leak in BottomSheetBackdrop that occurs when the backdrop tries to set the
pointerEvents
tonone
when dismissing the modal. If thedisappearsOnIndex
is set to-1
and theanimatedIndex
is<= -1
, there is no need to callsetEventPointers
since the modal should be removed.
here's the patch if anyone is interested:
diff --git a/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetBackdrop/BottomSheetBackdrop.tsx b/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetBackdrop/BottomSheetBackdrop.tsx
index 35597ce..964bc25 100644
--- a/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetBackdrop/BottomSheetBackdrop.tsx
+++ b/node_modules/@gorhom/bottom-sheet/src/components/bottomSheetBackdrop/BottomSheetBackdrop.tsx
@@ -105,7 +105,7 @@ const BottomSheetBackdropComponent = ({
useAnimatedReaction(
() => animatedIndex.value <= disappearsOnIndex,
(shouldDisableTouchability, previous) => {
- if (shouldDisableTouchability === previous) {
+ if (shouldDisableTouchability === previous || disappearsOnIndex === -1) {
return;
}
runOnJS(handleContainerTouchability)(shouldDisableTouchability);
using local patch until we wait for this to get merged, @gorhom appreciate when you have some time to review it
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.
@gorhom waiting for this PR to be merged. Could you please check this PR and merge
In my experience this fix prevents the bottom-sheet from opening on the first try. This pull request needs to be developed. Be careful before use.
@tsukudabuddha thanks for submitting this PR, do you have a detailed issue reported i could verify the fix with?
@gorhom here's an issue with more details: #1376