Skip to content

Memoize Text component - #4003

Merged
m-bert merged 16 commits into
mainfrom
@mbert/memo-text
Mar 2, 2026
Merged

Memoize Text component#4003
m-bert merged 16 commits into
mainfrom
@mbert/memo-text

Conversation

@m-bert

@m-bert m-bert commented Feb 27, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR introduces 3 changes to Text component

  • Removes forwardedRef
  • Adds memoization

Test plan

Tested on "Nested Text" example

Copilot AI review requested due to automatic review settings February 27, 2026 12:04
@m-bert
m-bert marked this pull request as ready for review February 27, 2026 12:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Text to LegacyText at the package entrypoint.
  • Reworked the Text wrapper implementation (removed forwardRef, memoized Gesture.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.

Comment thread packages/react-native-gesture-handler/src/components/Text.tsx Outdated
Comment thread packages/react-native-gesture-handler/src/index.ts
Comment thread packages/react-native-gesture-handler/src/components/Text.tsx
Comment thread packages/react-native-gesture-handler/src/components/Text.tsx Outdated
Comment thread packages/react-native-gesture-handler/src/components/Text.tsx
Comment thread packages/react-native-gesture-handler/src/components/Text.tsx Outdated
Comment thread packages/react-native-gesture-handler/src/components/Text.tsx Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/react-native-gesture-handler/src/components/Text.tsx Outdated
Comment thread packages/react-native-gesture-handler/src/components/Text.tsx
Comment thread packages/react-native-gesture-handler/src/components/Text.tsx Outdated
Comment thread packages/react-native-gesture-handler/src/components/Text.tsx Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/react-native-gesture-handler/src/components/Text.tsx
Comment thread packages/react-native-gesture-handler/src/components/Text.tsx Outdated
Comment on lines 16 to 18
/**
* @deprecated `LegacyText` is deprecated. Since Gesture Handler 3 you can wrap `Text` with `GestureDetector`.
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* @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`.
*/

@m-bert
m-bert merged commit 7406046 into main Mar 2, 2026
2 checks passed
@m-bert
m-bert deleted the @mbert/memo-text branch March 2, 2026 11:57
m-bert added a commit that referenced this pull request Apr 2, 2026
This PR introduces 3 changes to `Text` component

- Removes `forwardedRef`
- Adds memoization

Tested on "Nested Text" example
Copilot AI pushed a commit that referenced this pull request Apr 2, 2026
This PR introduces 3 changes to `Text` component

- Removes `forwardedRef`
- Adds memoization

Tested on "Nested Text" example

Co-authored-by: m-bert <63123542+m-bert@users.noreply.github.com>
m-bert added a commit that referenced this pull request Apr 2, 2026
## 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants