Update Swipeable types#4175
Draft
m-bert wants to merge 10 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the public TypeScript API for ReanimatedSwipeable to reflect that certain numeric configuration props may be provided as Reanimated SharedValue<number>, aligning the typings/docs with intended usage.
Changes:
- Expand
SwipeableProps.dragOffsetFromLeftandSwipeableProps.dragOffsetFromRightto acceptSharedValue<number>in addition tonumber. - Update the Reanimated Swipeable docs to reflect the updated prop types.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts | Widens dragOffsetFromLeft/dragOffsetFromRight prop types to include SharedValue<number>. |
| packages/docs-gesture-handler/docs/components/reanimated_swipeable.mdx | Updates the documented TypeScript signatures for the same props. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx:489
activeOffsetXrequires the first tuple element to be <= 0 and the second to be >= 0 (validated byusePanGesturein DEV). Switching to[dragOffsetFromRight, dragOffsetFromLeft]changes the sign contract fordragOffsetFromRightcompared to the documented/default behavior ("Defaults to 10"), and will break existing callers passing a positive number. Prefer preserving the existing API (positive distance) and handling the negation internally in a way that supportsSharedValue, or update the default value + docs to explicitly require a non-positivedragOffsetFromRight.
const panGesture = usePanGesture({
enabled: enabled !== false,
enableTrackpadTwoFingerGesture: enableTrackpadTwoFingerGesture,
activeOffsetX: [dragOffsetFromRight, dragOffsetFromLeft],
simultaneousWith,
requireToFail,
Comment on lines
+68
to
+78
| useEffect(() => { | ||
| if (__DEV__) { | ||
| const value = maybeUnpackValue<number>(dragOffsetFromRight); | ||
|
|
||
| if (value > 0) { | ||
| throw new Error( | ||
| tagMessage('dragOffsetFromRight should be non-positive.') | ||
| ); | ||
| } | ||
| } | ||
| }, [dragOffsetFromRight]); |
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
Some of the props passed to
Swipeablecan beSharedValue. However, we do not allow that in types, so TypeScript throws errors.Test plan
Static checks