Skip to content

[General] Allow to create gestures with no config#4115

Open
j-piasecki wants to merge 1 commit intomainfrom
@jpiasecki/no-config-gestures
Open

[General] Allow to create gestures with no config#4115
j-piasecki wants to merge 1 commit intomainfrom
@jpiasecki/no-config-gestures

Conversation

@j-piasecki
Copy link
Copy Markdown
Member

Description

Updates gesture hook signatures to include the default, empty config for each gesture. This allows for creating gesture objects without passing a config, like so:

const nativeGesture = useNativeGesture()

Native gesture would be the most useful here, since its config is often empty when pulling in a host component into RNGH's gesture system. Other gestures may be a nice DX improvement, though, since now it's simpler to create a "placeholder" gesture.

The default config is referentially stable, so it shouldn't cause unnecessary updates between renders as opposed to passing an empty object (with no compiler and memoization).

Test plan

Static checks

Copilot AI review requested due to automatic review settings April 24, 2026 08:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the API v3 gesture hook signatures to allow creating gesture objects without providing a config argument, by defaulting the config to a referentially stable empty object.

Changes:

  • Add per-hook EMPTY_*_CONFIG constants and default the config parameter to them.
  • Enable calling gesture hooks with no arguments (e.g., useNativeGesture()), while keeping memoization stable across renders.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/react-native-gesture-handler/src/v3/hooks/gestures/tap/useTapGesture.ts Default config to a stable empty Tap config.
packages/react-native-gesture-handler/src/v3/hooks/gestures/rotation/useRotationGesture.ts Default config to a stable empty Rotation config.
packages/react-native-gesture-handler/src/v3/hooks/gestures/pinch/usePinchGesture.ts Default config to a stable empty Pinch config.
packages/react-native-gesture-handler/src/v3/hooks/gestures/pan/usePanGesture.ts Default config to a stable empty Pan config (including DEV validation path).
packages/react-native-gesture-handler/src/v3/hooks/gestures/native/useNativeGesture.ts Default config to a stable empty Native config.
packages/react-native-gesture-handler/src/v3/hooks/gestures/manual/useManualGesture.ts Default config to a stable empty Manual config.
packages/react-native-gesture-handler/src/v3/hooks/gestures/longPress/useLongPressGesture.ts Default config to a stable empty LongPress config.
packages/react-native-gesture-handler/src/v3/hooks/gestures/hover/useHoverGesture.ts Default config to a stable empty Hover config.
packages/react-native-gesture-handler/src/v3/hooks/gestures/fling/useFlingGesture.ts Default config to a stable empty Fling config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants