Skip to content

Commit be494f6

Browse files
committed
mute
1 parent a085508 commit be494f6

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,43 @@ hydrateRoot(document, <App />);
231231
232232
---
233233
234+
### كتم تحذيرات الربط غير المرتبطة بالترطيب {/*suppressing-unavoidable-hydration-mismatch-errors*/}
235+
236+
إذا كان هناك اختلاف ضروري بين سمة عنصر واحد أو محتوى النص بين الخادم والعميل (على سبيل المثال ، الطابع الزمني)، فيمكنك إسكات تحذيرات الربط غير المرتبطة بالترطيب.
237+
238+
لكتم تحذيرات الربط على عنصر ما، أضف `suppressHydrationWarning={true}`:
239+
240+
<Sandpack>
241+
242+
```html public/index.html
243+
<!--
244+
HTML content inside <div id="root">...</div>
245+
was generated from App by react-dom/server.
246+
-->
247+
<div id="root"><h1>Current Date: <!-- -->01/01/2020</h1></div>
248+
```
249+
250+
```js index.js
251+
import './styles.css';
252+
import { hydrateRoot } from 'react-dom/client';
253+
import App from './App.js';
254+
255+
hydrateRoot(document.getElementById('root'), <App />);
256+
```
257+
258+
```js App.js active
259+
export default function App() {
260+
return (
261+
<h1 suppressHydrationWarning={true}>
262+
Current Date: {new Date().toLocaleDateString()}
263+
</h1>
264+
);
265+
}
266+
```
267+
268+
</Sandpack>
269+
270+
هذا يعمل فقط لعنصر واحد عميق، ومقصود أن يكون هروبًا. لا تستخدمه بكثرة. ما لم يكن هو محتوى النص، فإن React لن يحاول تصحيحه، وبالتالي قد يظل غير متسق حتى التحديثات المستقبلية.
271+
272+
---
273+

0 commit comments

Comments
 (0)