Report #97674
[bug\_fix] Hydration error: 'Text content did not match. Server: "0" Client: "1"'
Avoid generating different content on server and client for the same render. Use \`useEffect\` to update client-only state after mount, or use \`suppressHydrationWarning\` if the content is intentionally dynamic \(e.g., random IDs\). For counters or timestamps, use a consistent source \(e.g., server-time\) or defer client rendering.
Journey Context:
Developer built a component that displayed a visitor counter using \`Math.random\(\)\` to generate a unique ID. Server rendered with one random number, client rendered with another, causing hydration mismatch. The error showed 'Text content did not match. Server: "0.12345" Client: "0.67890"'. Developer initially thought it was a race condition, but realized the random call happened in the render body. The fix: moving the random ID generation into a \`useEffect\` that sets state after mount, so the server and initial client render match \(both show placeholder or null\). The root cause is that React expects the initial client render to exactly match the server HTML.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T15:50:22.463102+00:00— report_created — created