-
Notifications
You must be signed in to change notification settings - Fork 25k
chore: convert View to React 19 #51023
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
chore: convert View to React 19 #51023
Conversation
yungsters
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.
I tried using flow
componentkeyword but it's not enabled in this project. Given thereact-nativepackage is shipped untranspiled, it's probably safer to avoid newer flow types.
Since React Native now requires using hermes-parser anyway, Component Syntax should work. However, we have not yet adopted it because of some tooling blockers being tracked by @pieterv and @poteto.
It's unclear the exact right way to type a ref since it should be optional for external users of the component but required inside the component.
What you have seems fine. But what do you mean by "required inside the component"?
| import * as React from 'react'; | ||
|
|
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.
We should also switch to destructuring these imports as recommended by React docs.
| import * as React from 'react'; | |
| import * as React from 'react'; | |
| import {use} from 'react'; | |
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.
Was matching the style in LogBox
Co-authored-by: Timothy Yung <yungsters@gmail.com>
|
@yungsters has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
Thanks for the update. Heads up, I'll be making a couple changes in the commit to reduce breaking changes.
|
|
@yungsters merged this pull request in eedd60b. |
|
This pull request was successfully merged by @EvanBacon in eedd60b When will my fix make it into a release? | How to file a pick request? |
| return <TextAncestor value={false}>{actualView}</TextAncestor>; | ||
| } | ||
|
|
||
| View.displayName = 'View'; |
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.
Was this deleted on purpose? We started getting View_withRef in snapshot tests in Reanimated instead of the View tag after this change and I wonder if this is the expected behavior and we should update all snapshots or if it was a mistake and the displayName should still be set to View?
Summary: Hello, I work on [Radon IDE](ide.swmansion.com) I encountered an issue while adding support for react native 81, this PR solves it: In #51023 EvanBacon removed `displayName` filed from `View` component adding the following comment: >Remove displayName in favor of component name. I'm not 100% sure this is a full fallback but it is valid according to react/display-name eslint rule—https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/display-name.md Unfortunately the Fabric renderer uses the `displayName` property to generate the name of the component for the inspector functionality and in absence of it generates a name that might be confusing to the end user: <img width="351" height="283" alt="Screenshot 2025-07-17 at 21 27 37" src="https://github.com/user-attachments/assets/852246aa-6586-4684-b80e-5d70b9678c6e" /> Problem is not specific to Radon and happens in chrome devtools as well: <img width="501" height="130" alt="Screenshot 2025-07-17 at 22 16 52" src="https://github.com/user-attachments/assets/3514dd02-59f7-473a-87b1-6ed325d2034c" /> This PR brings back the `displayName` property to fix that. ## Changelog: [INTERNAL] [FIXED] - Bring back the displayName property to the View component Pull Request resolved: #52688 Test Plan: - Run the application - open chrome devtools and navigate to "components" tab - before changes the View components would show up as `View_withRef` after they are named `View` Rollback Plan: Reviewed By: lunaleaps, cortinico Differential Revision: D78512254 Pulled By: alanleedev fbshipit-source-id: 46e4a224b09fe3fb938c055a675f687c86d7ddcb
Summary: Hello, I work on [Radon IDE](ide.swmansion.com) I encountered an issue while adding support for react native 81, this PR solves it: In facebook#51023 EvanBacon removed `displayName` filed from `View` component adding the following comment: >Remove displayName in favor of component name. I'm not 100% sure this is a full fallback but it is valid according to react/display-name eslint rule—https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/display-name.md Unfortunately the Fabric renderer uses the `displayName` property to generate the name of the component for the inspector functionality and in absence of it generates a name that might be confusing to the end user: <img width="351" height="283" alt="Screenshot 2025-07-17 at 21 27 37" src="https://github.com/user-attachments/assets/852246aa-6586-4684-b80e-5d70b9678c6e" /> Problem is not specific to Radon and happens in chrome devtools as well: <img width="501" height="130" alt="Screenshot 2025-07-17 at 22 16 52" src="https://github.com/user-attachments/assets/3514dd02-59f7-473a-87b1-6ed325d2034c" /> This PR brings back the `displayName` property to fix that. [INTERNAL] [FIXED] - Bring back the displayName property to the View component Pull Request resolved: facebook#52688 Test Plan: - Run the application - open chrome devtools and navigate to "components" tab - before changes the View components would show up as `View_withRef` after they are named `View` Rollback Plan: Reviewed By: lunaleaps, cortinico Differential Revision: D78512254 Pulled By: alanleedev fbshipit-source-id: 46e4a224b09fe3fb938c055a675f687c86d7ddcb
Summary: Hello, I work on [Radon IDE](ide.swmansion.com) I encountered an issue while adding support for react native 81, this PR solves it: In #51023 EvanBacon removed `displayName` filed from `View` component adding the following comment: >Remove displayName in favor of component name. I'm not 100% sure this is a full fallback but it is valid according to react/display-name eslint rule—https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/display-name.md Unfortunately the Fabric renderer uses the `displayName` property to generate the name of the component for the inspector functionality and in absence of it generates a name that might be confusing to the end user: <img width="351" height="283" alt="Screenshot 2025-07-17 at 21 27 37" src="https://github.com/user-attachments/assets/852246aa-6586-4684-b80e-5d70b9678c6e" /> Problem is not specific to Radon and happens in chrome devtools as well: <img width="501" height="130" alt="Screenshot 2025-07-17 at 22 16 52" src="https://github.com/user-attachments/assets/3514dd02-59f7-473a-87b1-6ed325d2034c" /> This PR brings back the `displayName` property to fix that. [INTERNAL] [FIXED] - Bring back the displayName property to the View component Pull Request resolved: #52688 Test Plan: - Run the application - open chrome devtools and navigate to "components" tab - before changes the View components would show up as `View_withRef` after they are named `View` Rollback Plan: Reviewed By: lunaleaps, cortinico Differential Revision: D78512254 Pulled By: alanleedev fbshipit-source-id: 46e4a224b09fe3fb938c055a675f687c86d7ddcb Co-authored-by: filip131311 <159789821+filip131311@users.noreply.github.com>
Summary: Hello, I work on [Radon IDE](ide.swmansion.com) I encountered an issue while adding support for react native 81, this PR solves it: In facebook#51023 EvanBacon removed `displayName` filed from `View` component adding the following comment: >Remove displayName in favor of component name. I'm not 100% sure this is a full fallback but it is valid according to react/display-name eslint rule—https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/display-name.md Unfortunately the Fabric renderer uses the `displayName` property to generate the name of the component for the inspector functionality and in absence of it generates a name that might be confusing to the end user: <img width="351" height="283" alt="Screenshot 2025-07-17 at 21 27 37" src="https://github.com/user-attachments/assets/852246aa-6586-4684-b80e-5d70b9678c6e" /> Problem is not specific to Radon and happens in chrome devtools as well: <img width="501" height="130" alt="Screenshot 2025-07-17 at 22 16 52" src="https://github.com/user-attachments/assets/3514dd02-59f7-473a-87b1-6ed325d2034c" /> This PR brings back the `displayName` property to fix that. ## Changelog: [INTERNAL] [FIXED] - Bring back the displayName property to the View component Pull Request resolved: facebook#52688 Test Plan: - Run the application - open chrome devtools and navigate to "components" tab - before changes the View components would show up as `View_withRef` after they are named `View` Rollback Plan: Reviewed By: lunaleaps, cortinico Differential Revision: D78512254 Pulled By: alanleedev fbshipit-source-id: 46e4a224b09fe3fb938c055a675f687c86d7ddcb
Summary:
forwardRefin favor of built-inrefprop.useAPI instead ofuseContext..ProviderforTextAncestorcontext.displayNamein favor of component name. I'm not 100% sure this is a full fallback but it is valid according toreact/display-nameeslint rule—https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/display-name.mdcomponentkeyword but it's not enabled in this project. Given thereact-nativepackage is shipped untranspiled, it's probably safer to avoid newer flow types.refisn't defined.Changelog:
[GENERAL] [BREAKING] Upgrade
Viewcomponent to React 19.Test Plan: