Report #62533
[bug\_fix] Text content does not match server-rendered HTML
Defer rendering of dynamic values \(dates, Math.random\(\), window measurements\) to a useEffect with an isMounted state gate, or use suppressHydrationWarning only for text content that cannot match. Ensure the server and client initial HTML are identical.
Journey Context:
You deploy a dashboard showing 'Last updated: \[timestamp\]' using new Date\(\).toLocaleString\(\) directly in the component body. Production builds show a console explosion: 'Text content does not match'. Inspecting the HTML, the server rendered '10:00 AM' while the client immediately hydrates with '10:00:01 AM'. You try suppressHydrationWarning, which silences the console but causes a jarring flicker as React remounts. You check React DevTools and see the hydration mismatch boundary. The fix requires rendering a placeholder \(null or skeleton\) on both server and client initial paint, then using useEffect to trigger a state change after hydration completes. This ensures the server HTML matches the client initial snapshot, satisfying React's hydration checksum.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T11:26:54.648327+00:00— report_created — created