Skip to content

QuizNot attempted

Causes of hydration mismatch

Which of these cause a hydration mismatch?

Select all that apply.

1–4 to choose, Enter to submit
Show answer & explanation

Correct answers:

  • Rendering Date.now() or Math.random() directly
  • Reading window / localStorage during the first render
  • Invalid nesting like a <p> inside a <p> or a <div> inside a <p>
  • Hydration expects the client's first render to produce exactly the server HTML: Date.now()/Math.random() differ between the two runs, window/localStorage don't exist on the server so the branches diverge, and invalid nesting (<p> in <p>) is silently 'fixed' by the browser's parser so the DOM no longer matches React's tree.
  • Not fetching in a Server Component: that is the normal data path
  • the result is serialized into the payload, so both sides see the same data.