Closed orangecoloured closed 2 years ago
Please provide a reproduction, what you've listed is not enough to go on.
We just hydrate over the first child if you've prerendered.
@rschristian here you go https://github.com/orangecoloured/ssr-hidden-component-test
There's a TestComponent
which renders normally while dev
. When you build
and then serve
the project you'll notice the layout is messed up upon page load. The generated layout is correct though.
Thanks for the reproduction, it helped me understand what you were referring to.
This is correct behavior, see https://github.com/preactjs/preact/issues/2572
Hydrate expects content to match -- it's a fast path around rendering built for this purpose. You need to make your content match, or get closer to it with placeholder elements, as full diffing isn't done.
What is the current behaviour? I have several pages with hidden for SSR render components. The pre-rendered code looks fine, but as soon as JS fires up it messes up the layout.
How the raw source code looks like:
How it looks like when the page is loaded:
The last node is duplicated and each previous node is wrapped in the next sibling's wrapping node.
Steps to Reproduce Steps to reproduce the behavior:
What is the expected behaviour? The behaviour is the same as in dev mode.