File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ permalink: docs/refs-and-the-dom.html
13
13
14
14
Refs 提供了一种方式,允许我们访问 DOM 节点或在 render 方法中创建的 React 元素。
15
15
16
- 在典型的 React 数据流中,[ props] ( /docs/components-and-props.html ) 是唯一一个让父组件与子组件交互的唯一方式 。要修改一个子组件,你需要使用新的 props 来重新渲染它。
16
+ 在典型的 React 数据流中,[ props] ( /docs/components-and-props.html ) 是父组件与子组件交互的唯一方式 。要修改一个子组件,你需要使用新的 props 来重新渲染它。
17
17
但是,在某些情况下,你需要在典型数据流之外强制修改子组件。被修改的子组件可能是一个 React 组件的实例,也可能是一个 DOM 元素。对于这两种情况,React 都提供了解决办法。
18
18
19
19
### 何时使用 Refs {#when-to-use-refs}
@@ -288,4 +288,4 @@ class Parent extends React.Component {
288
288
289
289
### 关于回调 refs 的警告 {#caveats-with-callback-refs}
290
290
291
- 如果 ` ref ` 回调函数是以内联函数的方式定义的,在更新过程中它会被执行两次,第一次传入参数 ` null ` ,然后第二次会传入参数 ` DOM ` 元素。这是因为在每次渲染时会创建一个新的函数实例,所以 React 清空旧的 ref 并且设置新的。通过将 ref 的回调函数定义成类的绑定函数的方式可以避免上述问题,但是大多数情况下它是无关紧要的。
291
+ 如果 ` ref ` 回调函数是以内联函数的方式定义的,在更新过程中它会被执行两次,第一次传入参数 ` null ` ,然后第二次会传入参数 ` DOM ` 元素。这是因为在每次渲染时会创建一个新的函数实例,所以 React 清空旧的 ref 并且设置新的。通过将 ref 的回调函数定义成类的绑定函数的方式可以避免上述问题,但是大多数情况下它是无关紧要的。
You can’t perform that action at this time.
0 commit comments