Memoize Text component - #4003
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Gesture Handler Text wrapper component by renaming it to LegacyText and adjusting its implementation to remove forwardRef and add memoization for the native gesture instance, with the example app updated accordingly.
Changes:
- Renamed the exported component from
TexttoLegacyTextat the package entrypoint. - Reworked the
Textwrapper implementation (removedforwardRef, memoizedGesture.Native()instance). - Updated the “Nested Text” release test to use
LegacyText.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| packages/react-native-gesture-handler/src/index.ts | Renames the public export from Text to LegacyText. |
| packages/react-native-gesture-handler/src/components/Text.tsx | Reimplements the wrapper as LegacyText, changes ref handling approach, and memoizes the native gesture. |
| apps/common-app/src/legacy/release_tests/nestedText/index.tsx | Migrates the test example to import/use LegacyText. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /** | ||
| * @deprecated `LegacyText` is deprecated. Since Gesture Handler 3 you can wrap `Text` with `GestureDetector`. | ||
| */ |
There was a problem hiding this comment.
| /** | |
| * @deprecated `LegacyText` is deprecated. Since Gesture Handler 3 you can wrap `Text` with `GestureDetector`. | |
| */ | |
| /** | |
| * @deprecated `LegacyText` is deprecated. Since Gesture Handler 3, you should wrap `Text` with `GestureDetector`, `InterceptingGestureDetector`, or `VirtualGestureDetector`. | |
| */ |
## Description Cherry pick thread for release 2.31.0 ## List of PRs - #3983 - #3987 - #3989 - #3991 - #4010 - #4015 - #4020 - #4029 - [Already existing] #4039 - #4047 ## Needs double-check - #3964 - [Original commit](560d1b5#diff-3a70a725140527b922181806417d7510bb1c7a19ee9243a0dce4ce7d826ab235) - [Cherry-picked commit](058addc) - Follow up: [85c364a](85c364a) - #4003 - [Original commit](7406046) - [Cherry-picked commit](92b3bca) - #4012 - [Original commit](58c4641) - [Cherry-picked commit](4225660) - This is only TS check so I think it shouldn't break anything - #4023 - [Original commit](3918d8a) - [Cherry-picked commit](e7e8506) - I've checked that only formatting part was skipped, so up to you if you want to check that as well ## Test plan 🚀 --------- Co-authored-by: Janic Duplessis <janicduplessis@gmail.com> Co-authored-by: Wojciech Lewicki <wojciech.lewicki@swmansion.com> Co-authored-by: Andreas Högström <andreas.hogstrom@navigraph.com> Co-authored-by: YevheniiKotyrlo <44449990+YevheniiKotyrlo@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Jakub Piasecki <jakub.piasecki@swmansion.com> Co-authored-by: David Duarte <34779165+DavidDuarte22@users.noreply.github.com>
Description
This PR introduces 3 changes to
TextcomponentforwardedRefTest plan
Tested on "Nested Text" example