QuizNot attempted
Causes of hydration mismatch
1–4 to choose, Enter to submit
Show answer & explanation
Correct answers:
- Rendering
Date.now()orMath.random()directly - Reading
window/localStorageduring 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/localStoragedon'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.