-
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
Bug(@next): legacy ReactDOM.render
crashes when rendering into document
container
#26128
Comments
ReactDOM.render
crashes when rendering into document
containerReactDOM.render
crashes when rendering into document
container
I do believe the flag is on for the oss-stable build so it makes sense the code is showing up. I'll add a test and fix once I repro |
Oh right. It was initially shipped with |
as reported in #26128 `ReactDOM.render(..., document)` crashed when `enableHostSingletons` was on. This is because it had a different way of clearing the container than `createRoot(document)`. I updated the legacy implementation to share the clearing behavior of `creatRoot` which will preserve the singleton instances. I also removed the warning saying not to use `document.body` as a container
as reported in #26128 `ReactDOM.render(..., document)` crashed when `enableHostSingletons` was on. This is because it had a different way of clearing the container than `createRoot(document)`. I updated the legacy implementation to share the clearing behavior of `creatRoot` which will preserve the singleton instances. I also removed the warning saying not to use `document.body` as a container DiffTrain build for [a3152ed](a3152ed) [View git log for this commit](https://github.com/facebook/react/commits/a3152eda5f89e20f056521855f7fa101ce50e4c3)
Fixed in #26129 |
React version: 18.3.0-next-4bf2113a1-20230206
Steps To Reproduce
ReactDOM.render
into adocument
containerLink to code example: https://codesandbox.io/s/react-next-legacy-render-crashes-when-rendering-html-jqdut3?file=/src/index.js
The current behavior
Throws with
ReactDOM.render
clears the container before rendering into it. But with the new HostSingletons (#25426) we expect an existingdocumentElement
.The odd part is that it seems like #25426 affected the
@next
release even thoughenableHostSingletons
is disabled for that release./cc @gnoff
The expected behavior
No crash like in
[email protected]
: https://codesandbox.io/s/react-next-legacy-render-crashes-when-rendering-html-forked-977biyThe text was updated successfully, but these errors were encountered: