-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Suspense / ErrorBoundary content rendered twice when hydrating with render #4439
Description
- Check if updating to the latest Preact version resolves the issue
Describe the bug
We use ErrorBoundary and lazy from preact-iso for code-splitting our application but still being able to server-side render them in advance. With the upgrade to >10.19.0, we noticed that all our lazy components are rendered twice when first server-side rendered.
One important thing to note is that we use render instead of hydrate for hydrating our server-side rendered HTML because the server-side markup differs from what we render on the client. The bug does not appear when using hydrate. But changing that behaviour in our application would take an immense effort.
Switching from ErrorBoundary to Suspense did not solve the bug.
To Reproduce
- Go to https://codepen.io/phmitterer/pen/eYwYrpB
- Server-side rendering is simulated and "Hello, World!" is rendered
- After 1 second, client-side hydration kicks in and renders a second "Hello, World!"
Here is the same bug with Suspense instead of ErrorBoundary: https://codepen.io/phmitterer/pen/oNrNOVJ
Expected behavior
"Hello, World!" is only rendered once.