Skip to content

fix!: migrate pan gesture to Gesture Handler 3 - #3

Merged
marqroldan merged 3 commits into
mainfrom
fix/2-gesture-handler-3-pan-hook
Aug 20, 2026
Merged

marqroldan merged 3 commits into
mainfrom
fix/2-gesture-handler-3-pan-hook

Conversation

@marqroldan

@marqroldan marqroldan commented Aug 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Replace the Gesture Handler 2 Gesture.Pan() builder with Gesture Handler 3's usePanGesture hook.
  • Preserve the drag lifecycle by mapping onBegin and onUpdate directly and mapping onEnd to onDeactivate.
  • Keep the snap worklet stable with useCallback and resolve the existing effect-dependency lint errors.
  • Require Gesture Handler 3 in the development and peer dependency ranges, document the compatibility boundary, and add a regression test.
  • Align the example app with Gesture Handler 3 and repair the repository's Yarn/TypeScript declarations so CI can install and typecheck reproducibly.

Why

Gesture Handler 3 routes builder gestures through its legacy detector bridge. In a Reanimated UI runtime that bridge can serialize an undefined state-manager module namespace and crash with:

Cannot read property 'GestureStateManager' of undefined

Using the v3 hook API avoids that legacy path entirely.

Fixes #2.

Breaking change

react-native-gesture-handler 3 or newer is now required. Gesture Handler 2 consumers should remain on react-native-snap-area@0.1.x, so this should be released as a compatibility-breaking version.

Verification

  • yarn install --cwd example --frozen-lockfile
  • yarn install --frozen-lockfile
  • yarn lint (passes with existing inline-style warnings)
  • yarn typecheck
  • yarn test --runInBand
  • yarn prepack
  • npm pack --dry-run
  • Verified generated CommonJS and ESM output use usePanGesture and contain no Gesture.Pan() call.
  • Verified the same migration in a downstream Expo Android production export.

@marqroldan
marqroldan merged commit c2e3d0a into main Aug 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support the React Native Gesture Handler 3 hook API

1 participant