Report #15920
[bug\_fix] Hydration mismatch due to dynamic data or browser extensions
Ensure server and client render identical initial HTML by deferring browser-dependent values \(dates, window sizes\) to useEffect with an isClient check, or add suppressHydrationWarning for unavoidable differences. Root cause: React requires the initial client render to match the server HTML exactly; mismatches break hydration and event delegation.
Journey Context:
Developer deploys a Next.js site with \`const date = new Date\(\).toLocaleString\(\)\` in a component body. Locally it works, but production logs flood with "Text content does not match" warnings. They inspect the HTML source and see the server rendered "1/15/2024, 10:00 AM" while the client hydration renders "1/15/2024, 3:00 PM" due to timezone differences. They attempt to fix by wrapping in useEffect but forget the empty dependency array, causing infinite re-renders. After reading the hydration docs, they implement a mounted state pattern: \`const \[mounted, setMounted\] = useState\(false\); useEffect\(\(\) => setMounted\(true\), \[\]\);\` and only render the date when mounted is true, ensuring server and client match on initial paint.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:21:30.515308+00:00— report_created — created