-
-
Notifications
You must be signed in to change notification settings - Fork 1k
V3 pressable #3907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
V3 pressable #3907
Conversation
|
Note that I temporarily reverted the broken changes in the shadow node. Without it, the pressable breaks on both android and ios. This change will be reverted before merge. |
| export type { | ||
| PressableProps, | ||
| PressableStateCallbackType, | ||
| } from './components/Pressable'; | ||
| export { default as Pressable } from './components/Pressable'; | ||
| PressableProps as LegacyPressableProps, | ||
| PressableStateCallbackType as LegacyPressableCallbackType, | ||
| } from './v3/components/Pressable'; | ||
| export { default as LegacyPressable } from './v3/components/Pressable'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the new one should be exported as Legacy (and we probably want to export the legacy one).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to remove 'v3' from path yesterday 😅. Fixed in ae6e532
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new one is not exported, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is exported, I added it to v3/index and we reexport everything from there.
m-bert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously in Pressable we had:
for (const gesture of gestures) {
gesture.enabled(isPressableEnabled);
gesture.runOnJS(true);
gesture.hitSlop(appliedHitSlop);
Object.entries(relationProps).forEach(([relationName, relation]) => {
applyRelationProp(
gesture,
relationName as RelationPropName,
relation as RelationPropType
);
});
}don't new gestures miss enabled and hitSlop?
Also, I don't really like that a lot of code is duplicated. I know that splitting Pressable component may not be worth it, but I don't think it makes sense to duplicate things such as StateMachine (cc @j-piasecki).
packages/react-native-gesture-handler/src/v3/components/Pressable.tsx
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/components/Pressable/Pressable.tsx
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/components/Pressable/Pressable.tsx
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/components/Pressable/Pressable.tsx
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/components/Pressable/Pressable.tsx
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/components/Pressable/PressableProps.tsx
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/components/Pressable/StateMachine.tsx
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/components/Pressable/stateDefinitions.ts
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/components/Pressable/utils.ts
Outdated
Show resolved
Hide resolved
…ble/Pressable.tsx Co-authored-by: Michał Bert <63123542+m-bert@users.noreply.github.com>
Co-authored-by: Michał Bert <63123542+m-bert@users.noreply.github.com>
…ble/Pressable.tsx Co-authored-by: Michał Bert <63123542+m-bert@users.noreply.github.com>
…ble/Pressable.tsx Co-authored-by: Michał Bert <63123542+m-bert@users.noreply.github.com>
packages/react-native-gesture-handler/src/v3/components/Pressable.tsx
Outdated
Show resolved
Hide resolved
m-bert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, please make sure that other Pressable examples work before merging.
Note
Some of them may crash at manual activation, it was fixed on main but not yet cherry-picked to next
Description
V3 implementation of pressable component
Test plan
Tested on the following example