question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Portal] Hydration failure in SSR when initially rendered

See original GitHub issue

This manifests itself in Dialog and AlertDialog when using Portal with DefaultOpen in SSR env.

https://codesandbox.io/s/friendly-morning-3ny0r5?file=/pages/index.tsx

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:6
  • Comments:6

github_iconTop GitHub Comments

7reactions
laozhucommented, Jul 1, 2022

The same issue here when working with next.js, any plan to fix this? Now my workaround is set the open to false default, then set it true in useEffect when page has mounted.

0reactions
andy-hookcommented, Oct 10, 2022

I’d like to know if this hydration error also relates to this issue. I’m conditionally rendering a Dialog or Button based on viewport size.

Not directly, no. The server has no concept of screen media size until it hits the client which is why is falls into the false block on server and hydrates true on desktop which reports a mismatch.

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-hydration-error - Next.js
When css-in-js libraries are not set up for pre-rendering (SSR/SSG) it will often lead to a hydration mismatch. In general this means the...
Read more >
React 18: Hydration failed because the initial UI does not ...
Hydration failed because the initial UI does not match what was rendered on the server. Live demo code is here. Live demo of...
Read more >
Handling the React server hydration mismatch error
The ideal fix would be for us to determine from React that the initial render of the component is actually the hydration render....
Read more >
The Perils of Rehydration - Josh W Comeau
Server-side rendering 101. To understand the problem, we need to first dig a little into how frameworks like Gatsby and Next.js differ from ......
Read more >
Understand and solve hydration errors in Vue.js - sum.cumo
If a component is initially mounted or hydrated in the DOM, it needs to precisely correspond to the HTML generated on the server...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found