-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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
Split ReactDOM entry point #17331
Split ReactDOM entry point #17331
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 900a54f:
|
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.
This is fine with me, I had the same thought the last time I was looking at that file
Details of bundled changes.Comparing: a7b4d51...900a54f react-dom
Size changes (experimental) |
Rather than ReactDOMLegacy, maybe another name might be more fitting? Heritage? Legacy makes the APIs feel less relevant and important. |
This file is internal naming and is consistent with other places we call it "legacy mode" in the codebase. So I wouldn't worry too much about that here. Generally this might be a discussion worth having (e.g. the docs also call it a "legacy mode" here). This discussion can probably be decoupled from this PR though. Early on I had the same concern. But given that we have a "half measure" Blocking Mode, it might make sense for the ecosystem to migrate to that when possible. In that sense, Legacy is truly "legacy" — it has semantics causing issues today (#14536, #15080), and it might be good to encourage moving away from it. We'll adjust the messaging as we get more info from people who try it. |
This is kind of subjective. I find it hard to navigate
ReactDOM.js
. It's long, mixes public API with implementation details, and mixes some injection with old APIs with new ones. It's hard to tell what's being used only by the old code, and what's only needed for legacy (or missing in modern code).This is a refactor that does no functional changes. It splits
ReactDOM.js
into:ReactDOM.js
: Entry point is lean and only does some injection and importing.ReactDOMRoot.js
: ExportscreateRoot
,createBlockingRoot
, andcreateLegacyRoot
(internal). This is the where the shared root implementation lives.ReactDOMLegacy.js
: All legacy APIs likefindDOMNode
,render
,hydrate
,unmountComponentAtNode
,unstable_renderSubtreeIntoContainer
, live here. This includes some batching and legacy hyration heuristics code that isn't used by the modern roots.Eventually we can move
ReactDOMLegacy.js
to a separate package entry point.I've also renamed
BatchedRoot
toBlockingRoot
(missed that during last refactoring).