diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useMountReactions.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useMountReactions.ts index 84732ddbb1..12c37f7cdb 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useMountReactions.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useMountReactions.ts @@ -28,6 +28,12 @@ export function useMountReactions( ) { useEffect(() => { return MountRegistry.addMountListener((gesture) => { + // The detector may already be unmounted when this fires; bail out to avoid + // updating a detached detector. + if (!state.isMounted) { + return; + } + // At this point the ref in the gesture config should be updated, so we can check if one of the gestures // set in a relation with the gesture got mounted. If so, we need to update the detector to propagate // the changes to the native side.