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

feat(v2): support/use React v17 by default #4218

Merged
merged 8 commits into from
Feb 12, 2021
Merged

feat(v2): support/use React v17 by default #4218

merged 8 commits into from
Feb 12, 2021

Conversation

lex111
Copy link
Contributor

@lex111 lex111 commented Feb 11, 2021

Motivation

This should allow React v17 to be used on Docusaurus websites.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

E2E test, I suppose.

Related PRs

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)

@lex111 lex111 requested a review from slorber as a code owner February 11, 2021 23:35
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Feb 11, 2021
@netlify
Copy link

netlify bot commented Feb 11, 2021

[V1] Deploy preview success

Built with commit 099bbae

https://deploy-preview-4218--docusaurus-1.netlify.app

@netlify
Copy link

netlify bot commented Feb 11, 2021

Deploy preview for docusaurus-2 ready!

Built with commit 099bbae

https://deploy-preview-4218--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Feb 11, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟢 Performance 91
🟢 Accessibility 96
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-4218--docusaurus-2.netlify.app/classic/

@github-actions
Copy link

github-actions bot commented Feb 11, 2021

Size Change: -1 B (0%)

Total Size: 156 kB

ℹ️ View Unchanged
Filename Size Change
website/build/assets/css/styles.********.css 17.6 kB 0 B
website/build/assets/js/main.********.js 109 kB 0 B
website/build/blog/2017/12/14/introducing-docusaurus/index.html 21.7 kB 0 B
website/build/docs/introduction/index.html 180 B 0 B
website/build/index.html 6.95 kB -1 B (0%)

compressed-size-action

@slorber
Copy link
Collaborator

slorber commented Feb 12, 2021

Surprisingly, it seems we are safe to upgrade to React 17, as the deprecated react-loadable method is still there until React 18 while it should have been removed in React 17.

The warning was updated:

image

To:

image


Will update a few things in this PR and merge that asap! thanks

@slorber slorber mentioned this pull request Feb 12, 2021
"react": "^16.8.4",
"react-dom": "^16.8.4"
"react": "^16.8.4 || ^17.0.0",
"react-dom": "^16.8.4 || ^17.0.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

FYI @lex111 , examples should only be updated with yarn examples:generate after a release, and generated from the officially published init cli.

This is because these examples are actually used by CodeSandbox so if you use new Docusaurus features/versions that are not yet released, all the CodeSandboxes may fail until you publish those new features to npm.

So, the idea is that the examples somehow lag behind, and we only update them just after releasing.
They'll update to React 17 once we release the new versions with the new init templates.

In this case it should not cause any trouble so I'll let these versions

@slorber
Copy link
Collaborator

slorber commented Feb 12, 2021

FYI I added a "@docusaurus/react-loadable" fork as the warning is annoying in dev and we are safe until React 18 gets released.

More infos: jamiebuilds/react-loadable#213 (comment)

BTW, the "module-alias" thing I added will also be useful to support a Preact mode during SSR. At least it's the solution used by NextJS:
https://github.com/preactjs/next-plugin-preact/blob/master/packages/next-plugin-preact/index.js

@lex111
Copy link
Contributor Author

lex111 commented Feb 12, 2021

It looks like we can't use React 17 on our site for v2.
By the way, instead of ^16.8.4 || ^17.0.0 we can just specify >=16.8.4 as peer dependency (or ^16.8.4 || ^17). Perhaps it would be better?

@slorber
Copy link
Collaborator

slorber commented Feb 12, 2021

By the way, instead of ^16.8.4 || ^17.0.0 we can just specify >=16.8.4 as peer dependency (or ^16.8.4 || ^17).

>= 16 means it's compatible with React 18, but it's not, because the lifecycles will likely be removed. ^17 is not bad but maybe the react team has fixed bugs in 17.0.0 and prefer us to use 0.1 ? not sure what's the best practice here but I think it's fine to have 0.1 as it is currently

It looks like we can't use React 17 on our site for v2.

Looked at that error, I think it will work now

@slorber
Copy link
Collaborator

slorber commented Feb 12, 2021

😅 now v1 fails

@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Feb 12, 2021
@slorber slorber changed the title chore(v2): allow React v17 as peer dependency feat(v2): support/use React v17 by default Feb 12, 2021
This was linked to issues Feb 12, 2021
@slorber
Copy link
Collaborator

slorber commented Feb 12, 2021

🥳 thanks, seems to work fine finally!

@slorber slorber merged commit 175d9c3 into master Feb 12, 2021
@lex111 lex111 deleted the lex111/react17 branch February 19, 2021 18:20
@lex111 lex111 added this to the v2.0.0-alpha.71 milestone Mar 1, 2021
This was referenced Mar 10, 2021
slorber added a commit that referenced this pull request Jul 22, 2021
* chore(v2): allow React v17 as peer dependency

* minor React 17 changes

* Revert examples

* Possible fix

* Use @docusaurus/react-loadable fork

* add back react-loadable to please eslint/ts/linters, even if it's unused in practice

* missing dependency bump

* move enzyme dependencies to docusaurus v1

Co-authored-by: slorber <lorber.sebastien@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support React 17 Use React 17 with Docusaurus v2
3 participants