Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new Clickable component in the react-native-gesture-handler library, intended to serve as a unified replacement for BaseButton, RectButton, and BorderlessButton. The component supports configurable visual feedback (underlay or whole-component opacity changes) and native Android ripple effects. Supporting changes include extracting visual style properties (background color, border radius, etc.) through to the native button in GestureHandlerButton, type improvements to RawButton and BorderlessButton, and a new example screen.
Changes:
- New
Clickablecomponent with configurable animation feedback (feedbackTarget,feedbackType,activeOpacity,underlayColor) and long-press support GestureHandlerButtonnow passes visual style properties (backgroundColor, borderRadius, border styles) to the nativeButtonComponent, andRawButtongets proper type generics- Example screen demonstrating
Clickablein various configurations (base, rect-like, borderless-like, custom)
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/v3/components/Clickable.tsx |
New Clickable component with animation, long-press, and ripple support |
src/v3/components/index.ts |
Exports Clickable and ClickableProps (from incorrect path) |
src/v3/index.ts |
Re-exports Clickable from components |
src/components/GestureHandlerButton.tsx |
Extracts visual properties (backgroundColor, border*) into buttonStyle passed to native button |
src/v3/components/GestureButtons.tsx |
Adds type generics to RawButton, extracts ref in BorderlessButton |
src/v3/types/NativeWrapperType.ts |
Adds ` |
apps/common-app/src/new_api/components/clickable/index.tsx |
Example screen showcasing Clickable configurations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/react-native-gesture-handler/src/v3/components/index.ts
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/components/Clickable/Clickable.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/react-native-gesture-handler/src/v3/components/Clickable/ClickableProps.ts
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/components/GestureHandlerButton.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/react-native-gesture-handler/src/v3/components/Clickable/Clickable.tsx
Outdated
Show resolved
Hide resolved
apps/common-app/src/new_api/components/clickable_stress/index.tsx
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/components/Clickable/Clickable.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| export const RawButton = createNativeWrapper(GestureHandlerButton, { | ||
| export const RawButton = createNativeWrapper< | ||
| ReturnType<typeof GestureHandlerButton>, |
There was a problem hiding this comment.
I don't think it makes sense to change this to unknown (cc @j-piasecki).
There was a problem hiding this comment.
No it doesn't, but the comment itself is valid. Why ReturnType<typeof GestureHandlerButton> instead of the actual ref type?
There was a problem hiding this comment.
Okay, it might be confusing, but TRef is what is actually wrapped with ref, not ref itself.
There was a problem hiding this comment.
Ok, but ReturnType of GestureHandlerButton will be something like ReactNode, no?
packages/react-native-gesture-handler/src/v3/components/GestureButtons.tsx
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/components/Clickable/Clickable.tsx
Outdated
Show resolved
Hide resolved
| onPressOut?.(e); | ||
|
|
||
| if (longPressTimeout.current !== undefined) { | ||
| clearTimeout(longPressTimeout.current); | ||
| longPressTimeout.current = undefined; | ||
| } |
There was a problem hiding this comment.
I have mixed feelings. I don't like adding more hooks to track onPressIn. Maybe we could call onPressOut after checking e.pointerInside. WDYT @j-piasecki?
There was a problem hiding this comment.
Isn't pointerInside change triggering onUpdate? If so, then yes.
There was a problem hiding this comment.
On Android onUpdate is triggered on each move. On iOS it seems that something is blocking it from being sent as in Android (I'm getting it kinda randomly while panning).
Do we wait with Clickable until we resolve this, or do we merge (and possibly ship) this component while looking for a solution?
| KINDA_BLUE: '#5f97c8', | ||
| ANDROID: '#34a853', | ||
| WEB: '#1067c4', | ||
| }; |
There was a problem hiding this comment.
Please use the common colours, if needed add new colours there.
packages/react-native-gesture-handler/src/v3/components/GestureButtons.tsx
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/components/Clickable/ClickableProps.ts
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/components/Clickable/Clickable.tsx
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/components/Clickable/Clickable.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…native-gesture-handler into @mbert/clickable
…lickable component
Description
This PR introduces new
Clickablecomponent, which is meant to be a replacement for buttons.Note
Docs for
Clickablewill be added in #4022, as I don't want to release them right away after merging this PR.borderlessFor now,
borderlessdoesn't work. I've tested clickable with some changes that allowborderlessripple to be visible, however we don't want to introduce them here because it would break other things. Also it should be generl fix, not in the PR with new component.Stress test
Render list with 2000 buttons 50 times (50ms delay between renders), drop 5 best and 5 worst results. Then calculate average.
On android tests were limited to 25 repetitions with dropout of 3 best and worst results. This is because of OOM error.
Stress test example is available in this PR.
Android
BaseButtonRectButtonBorderlessButtoniOS
BaseButtonRectButtonBorderlessButtonWeb
BaseButtonRectButtonBorderlessButtonTest plan
New examples