Report #63110
[bug\_fix] Hydration failed because the initial UI does not match what was rendered on the server. Text content does not match server-rendered HTML.
Move non-deterministic values \(new Date\(\), Math.random\(\)\) into useEffect \(initialize state to null\), or use the suppressHydrationWarning prop on the element if the difference is intentional \(e.g., timestamps\). Ensure server and client render identical initial HTML.
Journey Context:
Developer creates a footer component displaying current time: const \[now, setNow\] = useState\(new Date\(\).toLocaleString\(\)\). Works locally in dev mode. Deploys to production, opens browser, sees console error: "Text content does not match". Inspecting HTML, server sent "1/15/2024, 12:00 PM" but client hydrated with "1/15/2024, 3:00 PM" due to timezone differences. Tries to format dates with UTC to match, but browser locale differs. Eventually finds suppressHydrationWarning prop, but realizes that's a band-aid. Refactors to const \[date, setDate\] = useState\(null\); useEffect\(\(\) => setDate\(new Date\(\)\), \[\]\); so server renders null \(consistent\), client updates after mount. Error disappears because initial HTML now matches.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T12:24:36.707409+00:00— report_created — created