-
Notifications
You must be signed in to change notification settings - Fork 47.1k
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
Move createRoot/hydrateRoot to react-dom/client #23385
Merged
Merged
Commits on Feb 28, 2022
-
Move createRoot/hydrateRoot to /client
We want these APIs ideally to be imported separately from things you might use in arbitrary components (like flushSync). Those other methods are "isomorphic" to how the ReactDOM tree is rendered. Similar to hooks. E.g. importing flushSync into a component that only uses it on the client should ideally not also pull in the entry client implementation on the server. This also creates a nicer parity with /server where the roots are in a separate entry point. Unfortunately, I can't quite do this yet because we have some legacy APIs that we plan on removing (like findDOMNode) and we also haven't implemented flushSync using a flag like startTransition does yet. Another problem is that we currently encourage these APIs to be aliased by /profiling (or unstable_testing). In the future you don't have to alias them because you can just change your roots to just import those APIs and they'll still work with the isomorphic forms. Although we might also just use export conditions for them. For that all to work, I went with a different strategy for now where the real API is in / but it comes with a warning if you use it. If you instead import /client it disables the warning in a wrapper. That means that if you alias / then import /client that will inturn import the alias and it'll just work. In a future breaking changes (likely when we switch to ESM) we can just remove createRoot/hydrateRoot from / and move away from the aliasing strategy.
Configuration menu - View commit details
-
Copy full SHA for 3bc2424 - Browse repository at this point
Copy the full SHA 3bc2424View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1afe55a - Browse repository at this point
Copy the full SHA 1afe55aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3fe0a5a - Browse repository at this point
Copy the full SHA 3fe0a5aView commit details -
Configuration menu - View commit details
-
Copy full SHA for abc6824 - Browse repository at this point
Copy the full SHA abc6824View commit details -
Configuration menu - View commit details
-
Copy full SHA for ecedff2 - Browse repository at this point
Copy the full SHA ecedff2View commit details
Commits on Mar 1, 2022
-
Configuration menu - View commit details
-
Copy full SHA for c95aabf - Browse repository at this point
Copy the full SHA c95aabfView commit details -
Change order of react-dom, react-dom/client alias
I think the order matters here. The first one takes precedence.
Configuration menu - View commit details
-
Copy full SHA for 29e7b0c - Browse repository at this point
Copy the full SHA 29e7b0cView commit details -
Configuration menu - View commit details
-
Copy full SHA for f403f13 - Browse repository at this point
Copy the full SHA f403f13View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.