Report #35963
[bug\_fix] Text content does not match server-rendered HTML: Hydration failed because the initial UI does not match what was rendered on the server
Move client-only data generation \(new Date\(\), Math.random\(\), window checks\) into useEffect with useState initialization, or add suppressHydrationWarning to the element if the mismatch is benign. Root cause: Server renders HTML at build/request time with undefined/null/placeholder values while client hydrates with immediate browser APIs, causing checksum mismatch.
Journey Context:
Developer adds a timestamp footer with \{new Date\(\).toLocaleString\(\)\} to a shared layout. Production build succeeds, but browser console throws React hydration error pointing to the timestamp span. Developer tries suppressing the warning but realizes the server-rendered HTML contains the build-time date while client expects current time. After reading React docs, developer moves the date into a useEffect that only runs after mount, using a state variable initialized to null, ensuring server and client initial HTML match \(both null\), then client updates after hydration.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:50:16.494085+00:00— report_created — created