-
-
Notifications
You must be signed in to change notification settings - Fork 9k
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
fix(core): do not recreate ReactDOM Root, fix React warning on hot reload #10103
Conversation
@@ -387,4 +387,5 @@ interface Window { | |||
prefetch: (url: string) => false | Promise<void[]>; | |||
preload: (url: string) => false | Promise<void[]>; | |||
}; | |||
docusaurusRoot?: import('react-dom/client').Root; |
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.
Note to self
I decided to add a new attribute here because it's a mutable variable, unlike window.docusaurus
(which gets reassigned on hot reload and is also frozen, so it was complicated to add the mutable root here in practice)
✅ [V2]
To edit notification comments on pull requests, go to your Netlify site configuration. |
⚡️ Lighthouse report for the deploy preview of this PR
|
Size Change: +86 B (+0.01%) Total Size: 1.59 MB
ℹ️ View Unchanged
|
Motivation
Fix React 18 hot reloading warning:
Initially reported here: #10099 (comment)
Note: this is not a React v18.3 warning, we can also have it in v18.2.
Note: Docusaurus does not have React Fast Refresh support, but we probably should have that. It doesn't look super easy to support 😅
Test Plan
CI + Tests
Local dev, hot reload works for both MD and JS files
Test links
https://deploy-preview-10103--docusaurus-2.netlify.app/