QuizNot attempted
Fixing a client-only value
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
- Render a placeholder first, then set the time in
useEffect(two-pass rendering)
- Effects run only on the client after hydration, so render a placeholder that matches the server HTML, then set the real time in
useEffect(two-pass rendering). - Not 'use server': that marks Server Actions, it doesn't make rendering client-only.
- Not Suspense: nothing suspends
- the mismatched value still renders on both sides.
- Not useMemo: it still runs during render on both server and client, giving different strings.
- Alternatives:
dynamic(..., { ssr: false }), orsuppressHydrationWarningfor an intentional, harmless mismatch.