Skip to content
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

Add a page about React 18 & Concurrent React #3092

Merged
merged 3 commits into from
Jun 8, 2022
Merged

Add a page about React 18 & Concurrent React #3092

merged 3 commits into from
Jun 8, 2022

Conversation

cortinico
Copy link
Contributor

@cortinico cortinico commented Apr 26, 2022

I'm adding a page about React 18 and Concurrent React to the New Architecture section.
Feedbacks are welcome as always 👍

Fixes #787

@netlify
Copy link

netlify bot commented Apr 26, 2022

Deploy Preview for react-native ready!

Name Link
🔨 Latest commit 2b0f4d7
🔍 Latest deploy log https://app.netlify.com/sites/react-native/deploys/62a0b24a5b79060008482799
😎 Deploy Preview https://deploy-preview-3092--react-native.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

Great job and thank you for writing this.

I left a few comments here and there I think would simplify the article and make it more effective. Feel free to apply only those that convince you the most.

I was also thinkning: does it make sense to split the article in two?

  • React and React Native
  • Enable the Concurrent Root in your app

The first article could go in the New Architecture Intro or even in the Introduction section of the website, while the second could stay in the migrate to the new architecture.

:::info
**tl;dr** The first version of React Native compatible with React 18 is **0.69.0**.
Moreover, to use the [new features of React 18 (i.e. Concurrent React)](https://reactjs.org/blog/2022/03/29/react-v18.html),
you must migrate your React Native app to the New Architecture.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a link to the playbook here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

docs/react-18-and-react-native.md Outdated Show resolved Hide resolved
2. The React renderers **shipped** with React Native inside the [./Libraries/Renderer](https://github.com/facebook/react-native/tree/main/Libraries/Renderer) of React Native.

This practically means that you **can't bump** the version of React in your `package.json` to a later version,
as you will still be using the older renderer from the folder mentioned above. Bumping the react version in your package.json
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
as you will still be using the older renderer from the folder mentioned above. Bumping the react version in your package.json
as you will still be using the old renderer from the folder mentioned above. Bumping the react version in your `package.json`

docs/react-18-and-react-native.md Outdated Show resolved Hide resolved
docs/react-18-and-react-native.md Outdated Show resolved Hide resolved
docs/react-18-and-react-native.md Outdated Show resolved Hide resolved

React 18 introduced [several new features](https://reactjs.org/blog/2022/03/29/react-v18.html) related to concurrency, and new APIs such as `startTransition`/`useTransition`.

Please note that in order to use those feature, your React Native application **needs to be migrated** to the New Architecture (specifically needs to be rendering on Fabric).
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a link to the section migrate-your-app?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd either link to https://reactnative.dev/docs/new-architecture-intro or defer this to once #3029 has been merged

docs/react-18-and-react-native.md Outdated Show resolved Hide resolved
Comment on lines 130 to 136
### Users on React Native 0.69 not yet migrated to the New Architecture

Please note that users on React Native 0.69, but still on the Old Architecture won't benefit from the new React 18 features.

While you can still override the `isConcurrentRootEnabled` method, that value will have no effect on your rendering.
You will still be using the old React rendered, you won't benefit of any concurrent features, and you won't be able to use the new
`startTransition`/`useTransition` APIs.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll rephrase this with something more assertive, perhaps even replacing the section with a caution box

Suggested change
### Users on React Native 0.69 not yet migrated to the New Architecture
Please note that users on React Native 0.69, but still on the Old Architecture won't benefit from the new React 18 features.
While you can still override the `isConcurrentRootEnabled` method, that value will have no effect on your rendering.
You will still be using the old React rendered, you won't benefit of any concurrent features, and you won't be able to use the new
`startTransition`/`useTransition` APIs.
:::caution
Users on the Old Architecture won't benefit from the new React 18 features, despite being on React Native 0.69.
The `isConcurrentRootEnabled` methods are ignored when running on the new architecture.
:::

I think that the box will catch more the attention of the user.
What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do you feel about the current wording?

### Users on React Native 0.69 not yet migrated to the New Architecture

Note: Users on React Native 0.69, but still on the Old Architecture will still use React 17 mode even if React 18 is installed in the `package.json` file.

Overriding the `isConcurrentRootEnabled` method will have no effect on your app.

website/sidebars.json Show resolved Hide resolved
@cortinico
Copy link
Contributor Author

Thanks for the comments @cipolleschi @Simek 🙏 Just to follow up here, @rickhanlonii is going to push some updates to this branch to simplify the page a bit 👍

@Nikunj262
Copy link

routing should be platform independent

@cortinico
Copy link
Contributor Author

routing should be platform independent

How is this related to this PR @Nikunj262 ?

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

Good to me. I left a few nit comments to be more consistent with how we usually write about the New Architecture.

docs/react-18-and-react-native.md Outdated Show resolved Hide resolved
docs/react-18-and-react-native.md Outdated Show resolved Hide resolved
docs/react-18-and-react-native.md Outdated Show resolved Hide resolved
website/sidebars.json Show resolved Hide resolved
Co-authored-by: Riccardo <cipolleschi@fb.com>
@cortinico cortinico merged commit faad06b into main Jun 8, 2022
@cortinico cortinico deleted the nc/react-18 branch June 8, 2022 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document how React is upgraded in React Native
6 participants