Report #84855
[bug\_fix] Text content does not match server-rendered HTML. Warning: An error occurred during hydration.
Move browser-only logic \(Date.now, Math.random, window access\) inside a useEffect hook so it only executes after mounting, or add the \`suppressHydrationWarning\` prop to the element if the difference is benign \(e.g., timestamps\). Root cause: Server and client generate different HTML strings during the initial render, breaking React's checksum.
Journey Context:
Developer adds \`const now = new Date\(\).toLocaleString\(\)\` directly in the component body to show a timestamp. The page renders fine in dev, but on refresh or production build, the console throws a hydration mismatch error showing the server HTML differs from the client. The developer checks the diff and sees the timestamp string is different between server and client. They initially try to suppress the warning, but realize the real issue is that the server cannot know the client's timezone or current time. After reading the error link, they move the timestamp logic into a \`useEffect\` that only runs after mount, rendering a placeholder initially. This ensures server and client HTML match during hydration, then the client updates the DOM post-mount.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T01:01:07.163274+00:00— report_created — created