-
Notifications
You must be signed in to change notification settings - Fork 49.1k
Closed
Labels
React 18Bug reports, questions, and general feedback about React 18Bug reports, questions, and general feedback about React 18Type: Discussion
Description
I just realized that the way I was using the new hydrateRoot
API was completely wrong. Unfortunately, React issued no warnings when omitting the initial children like so
const container = document.getElementById("root");
container.innerHTML = renderToString(<input />);
const root = hydrateRoot(container);
root.render(<input />)
I was hoping for some kind of symetry between createRoot
and hydrateRoot
which was enforced by the fact that hydratedRoot.render(ui)
would actually issue hydration warnings (on the render()
call not during hydrateRoot()
):
const container = document.getElementById("root");
container.innerHTML = renderToString(<input />);
// no hydration warning
const root = hydrateRoot(container);
// now we do get a hydration warning
root.render(<h1 />)
Maybe this is me just being silly but I would've hoped for a hydration warning on hydrateRoot
. Otherwise there's no apparent indication (in an untyped world) that hydrateRoot(container).render(initialUI)
is most likely not what you wanted.
gaearon
Metadata
Metadata
Assignees
Labels
React 18Bug reports, questions, and general feedback about React 18Bug reports, questions, and general feedback about React 18Type: Discussion