Hydration Errors and the Usual Traps — Concept Check
Questions on Hydration Errors and the Usual Traps. The server rendered one thing and the browser expected another. Hydration mismatches have a short list of causes, and knowing it turns a baffling error into a two-minute fix.
Questions in this quiz
7 questions on Hydration Errors and the Usual Traps — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A developer notices that a component renders differently on the server and client, showing a date mismatch. What is the most likely cause?
- AThe date is formatted using Intl.NumberFormat
- BThe component uses suppressHydrationWarning
- CThe component skips server-side rendering
- DThe date is rendered without a fixed timezone
2.You encounter a hydration error pointing to an element wrapped in <p><div>...</div></p>. What is the root cause?
- AInvalid HTML nesting
- BA missing suppressHydrationWarning
- CA browser API used during render
- DA dynamic import issue
3.A developer uses Math.random() during server-side rendering and notices a mismatch on the client. How should this be fixed?
- AChange to a fixed value
- BUse dynamic imports
- CRender it in a useEffect
- DUse suppressHydrationWarning
4.A page works in development but breaks in production with a 'Text content did not match' error. What is a likely cause?
- AA date or number formatted without an explicit locale
- BInvalid HTML nesting
- CA dynamic import issue
- DA missing use client directive
5.A developer reads window.innerWidth during render and faces a ReferenceError on the server. What is the correct fix?
- AUse suppressHydrationWarning
- BSkip SSR for the component
- CRead it in useEffect
- DUse a blocking script in the head
6.A component uses localStorage.getItem('theme') during render and behaves unexpectedly. What is happening?
- AlocalStorage is undefined on the server
- BThe theme value is incorrect
- CThe server timezone differs
- DThe component is not mounted
7.What is the purpose of suppressHydrationWarning in React?
- ATo suppress warnings for a single element
- BTo skip SSR for the component
- CTo ensure consistent date formatting
- DTo fix invalid HTML nesting