fix: crash when mount listener fires after GestureDetector unmount (#4268)
## Description `useMountReactions` registers a `MountRegistry` listener in `useEffect`. That listener can fire after the owning `GestureDetector` has already unmounted (e.g. a related gesture mounts while this detector is gone). Calling `updateDetector` in that case updates a detached detector and can crash (occasionally in `findNodeHandle`). Guard with the existing `state.isMounted` flag — the same pattern `attachHandlers` already uses for the microtask after unmount. Credit to @hannojg for the original investigation/fix direction. ## Changes - In `useMountReactions`, return early from the mount listener when `!state.isMounted`. ## Why not `useLayoutEffect`? An earlier version of this PR also moved the subscription to `useIsomorphicLayoutEffect` (same phase as GestureDetector attach/drop). We A/B tested `useLayoutEffect` vs stock `useEffect`, both with this early return. Crash rates were equivalent; the `isMounted` check alone is sufficient, so this PR keeps `useEffect`.
J
Jakub Kosmydel committed
991ccb539e5edc1278fe6b9b2e11494cd3a6f6ee
Parent: bc605eb
Committed by GitHub <noreply@github.com>
on 8/6/2026, 9:18:55 AM