@@ -228,15 +228,16 @@ function MyComponent() {
228
228
229
229
如果 *不得不* 在渲染期间读取[或者写入](/reference/react/useState#storing-information-from-previous-renders),[使用 state](/reference/react/useState) 代替。
230
230
231
- 当你打破这些规则时,你的组件可能仍然可以工作,但我们添加到 React 的大多数新功能将依赖于这些预期行为。阅读更多关于[保持你的组件纯粹。](/learn/keeping-components-pure#where-you-can-cause-side-effects)
231
+ 当你打破这些规则时,你的组件可能仍然可以工作,但我们添加到 React 的大多数新功能将依赖于这些预期行为。阅读 [保持你的组件纯粹](/learn/keeping-components-pure#where-you-can-cause-side-effects) 以了解更多信息。
232
+ ` ` ` 。
232
233
233
234
< / Pitfall>
234
235
235
236
-- -
236
237
237
238
### 通过 ref 操作 DOM {/* manipulating-the-dom-with-a-ref*/ }
238
239
239
- 使用 ref 操作 [DOM](https://developer.mozilla.org/zh-CN/docs/Web/API/HTML_DOM_API) 是非常常见的。React 对此有内置支持 。
240
+ 使用 ref 操作 [DOM ](https: // developer.mozilla.org/zh-CN/docs/Web/API/HTML_DOM_API) 是非常常见的。React 内置了对它的支持 。
240
241
241
242
首先,声明一个 < CodeStep step= {3 }> initial value< / CodeStep> 为 ` null` 的 < CodeStep step= {1 }> ref 对象< / CodeStep>
242
243
@@ -265,7 +266,7 @@ function MyComponent() {
265
266
266
267
当节点从屏幕上移除时,React 将把 ` current` 属性设回 ` null` 。
267
268
268
- 阅读更多关于 [用 ref 操纵DOM ](/learn/manipulating-the-dom-with-refs)
269
+ 阅读 [用 ref 操纵 DOM ](/ learn/ m anipulating- the- dom- with - refs) 以了解更多信息。
269
270
270
271
< Recipes titleText= " Examples of manipulating the DOM with useRef" titleId= " examples-dom" >
271
272
@@ -532,7 +533,7 @@ function Video() {
532
533
// ...
533
534
` ` `
534
535
535
- 在这里,` playerRef` 本身是可以为空的。然而,你应该能够说服你的类型检查器 ,不存在 ` getPlayer ()` 返回 ` null ` 的情况。然后在你的事件处理程序中使用 ` getPlayer ()` 。
536
+ 在这里,` playerRef` 本身是可以为空的。然而,你应该能够使你的类型检查器确信 ,不存在 ` getPlayer()` 返回 ` null` 的情况。然后在你的事件处理程序中使用 ` getPlayer()` 。
536
537
537
538
< / DeepDive>
538
539
@@ -573,7 +574,7 @@ export default function MyInput({ value, onChange }) {
573
574
}
574
575
` ` `
575
576
576
- 然后像这样将其包装在 [` forwardRef` ](/reference/react/forwardRef):
577
+ 然后像这样将其包装在 [` forwardRef` ](/ reference/ react/ forwardRef) 里 :
577
578
578
579
` ` ` js {3,8}
579
580
import { forwardRef } from 'react';
@@ -593,4 +594,4 @@ export default MyInput;
593
594
594
595
然后,父级组件可以得到它的 ref。
595
596
596
- 阅读更多关于 [访问另一个组件的 DOM 节点](/learn/manipulating-the-dom-with-refs#accessing-another-components-dom-nodes)。
597
+ 阅读 [访问另一个组件的 DOM 节点](/ learn/ m anipulating- the- dom- with - refs#accessing- another- components- dom- nodes) 了解更多信息 。
0 commit comments