[General] Allow to create gestures with no config#4115
Open
j-piasecki wants to merge 1 commit intomainfrom
Open
[General] Allow to create gestures with no config#4115j-piasecki wants to merge 1 commit intomainfrom
j-piasecki wants to merge 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
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_*_CONFIGconstants and default theconfigparameter 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Nativegesture 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