Skip to content

Commit 636e68f

Browse files
committed
docs(react-dom): clarify hydration mismatch guidance and remove incorrect expectedErrors annotation
1 parent 9294864 commit 636e68f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/content/reference/react-dom/client/hydrateRoot.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ Uncaught Error: Hydration failed because the server rendered HTML didn't match t
552552
553553
#### Example mismatch {/*example-mismatch*/}
554554
555-
```js {expectedErrors: {'react-compiler': [2]}}
555+
```js
556556
function App() {
557557
return <div>{Math.random()}</div>;
558558
}
@@ -566,7 +566,7 @@ This renders a different value on the server and the client, so hydration fails.
566566
2. Look for changing values in render (`Math.random()`, `Date.now()`). Move them to server data or calculate them after hydration in [`useEffect`](/reference/react/useEffect).
567567
3. Keep browser-only code out of render. Read `window`, `document`, and similar APIs in [`useEffect`](/reference/react/useEffect) or an event handler.
568568
4. Make sure the first client render uses the same data as the server render.
569-
5. If one mismatch is expected (for example, a timestamp), use `suppressHydrationWarning={true}` on that element.
569+
5. If a mismatch is truly unavoidable, such as a one-off timestamp, use `suppressHydrationWarning={true}` as a last resort on the specific element. Apply it narrowly and avoid using it on large subtrees because it only silences the warning and does not fix the mismatch.
570570
571571
#### Isolating the component {/*isolating-the-component*/}
572572

0 commit comments

Comments
 (0)