-
Notifications
You must be signed in to change notification settings - Fork 47.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
Warn when createRoot() is called on existing root #17328
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 7b26e71:
|
We attach another container flag for purposes for the event system to know if we’re in a react root. Can we reuse that? |
Yeah I can unify them. That would also solve the iOS issue. |
Details of bundled changes.Comparing: be3bfa6...7b26e71 react-dom
ReactDOM: size: 0.0%, gzip: 🔺+0.1% Size changes (stable) |
Details of bundled changes.Comparing: be3bfa6...7b26e71 react-dom
ReactDOM: size: 0.0%, gzip: 0.0% Size changes (experimental) |
The behavior is pretty confusing: https://codesandbox.io/s/frosty-satoshi-z87yi
So this adds a warning. Will be useful to people who replace
.render()
with.createRoot().render()
without considering that they may be running it multiple times.I don't warn if you
.unmount()
first. That seems okay-ish. Maybe you really don't have access to the root instance but at least you can free the previous one.