react
hydration_error
ai_generated
true
Warning: Text content did not match. Server: 'X' Client: 'Y'
ID: react/text-content-mismatch
88%Fix Rate
90%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 18 | active | — | — | — |
Root Cause
SSR hydration mismatch. Server and client render different text. Common: dates, random values, browser APIs.
genericWorkarounds
-
95% success Use useEffect for browser-only values (dates, localStorage, window size)
const [time, setTime] = useState(''); useEffect(() => setTime(new Date().toLocaleString()), []); -
85% success Use suppressHydrationWarning only on the specific element with dynamic content
Use suppressHydrationWarning only on the specific element with dynamic content
Sources: https://react.dev/reference/react-dom/client/hydrateRoot
-
88% success Ensure server and client use the same data — pass SSR data via props, not new fetches
// Serialize SSR data into the HTML for client hydration: // Server renders a script tag with: window.__DATA__ = JSON.stringify(data) // Client: hydrateRoot(el, <App data={window.__DATA__} />)
Dead Ends
Common approaches that don't work:
-
suppressHydrationWarning on every element
70% fail
Hides the warning but the mismatch still causes visual flicker
-
Disable SSR entirely
65% fail
Loses SEO and initial load performance
Error Chain
Frequently confused with: