Skip to content

Bug(@next): legacy ReactDOM.render crashes when rendering into document container #26128

Closed
@eps1lon

Description

@eps1lon

React version: 18.3.0-next-4bf2113a1-20230206

Steps To Reproduce

  1. ReactDOM.render into a document container

Link 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

React expected an <html> element (document.documentElement) to exist in the Document but one was not found. React never removes the documentElement for any Document it renders into so the cause is likely in some other script running on this page.

ReactDOM.render clears the container before rendering into it. But with the new HostSingletons (#25426) we expect an existing documentElement.

The odd part is that it seems like #25426 affected the @next release even though enableHostSingletons is disabled for that release.

/cc @gnoff

The expected behavior

No crash like in react-dom@18.2.0: https://codesandbox.io/s/react-next-legacy-render-crashes-when-rendering-html-forked-977biy

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions