Skip to content

Commit

Permalink
docs(cn): fix link in content/docs/hooks-effect.md (reactjs#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDaraW authored and hijiangtao committed May 7, 2019
1 parent 18c5e93 commit 834192b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion content/docs/hooks-effect.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function Example() {
我们声明了 `count` state 变量,并告诉 React 我们需要使用 effect。紧接着传递函数给 `useEffect` Hook。此函数就是我们的 effect。然后使用 `document.title` 浏览器 API 设置 document 的 title。我们可以在 effect 中获取到最新的 `count` 值,因为他在函数的作用域内。当 React 渲染组件时,会保存已使用的 effect,并在更新完 DOM 后执行它。这个过程在每次渲染时都会发生,包括首次渲染。
经验丰富的 JavaScript 开发人员可能会注意到,传递给 `useEffect` 的函数在每次渲染中都会有所不同,这是刻意为之的。事实上这正是我们可以在 effect 中获取最新的 `count` 的值,而不用担心其过期的原因。每次我们重新渲染,都会生成_新的_ effect,替换掉之前的。某种意义上讲,effect 更像是渲染结果的一部分 —— 每个 effect “属于”一次特定的渲染。我们将在[本章节后续部分(#explanation-why-effects-run-on-each-update)]更清楚地了解这样做的意义。
经验丰富的 JavaScript 开发人员可能会注意到,传递给 `useEffect` 的函数在每次渲染中都会有所不同,这是刻意为之的。事实上这正是我们可以在 effect 中获取最新的 `count` 的值,而不用担心其过期的原因。每次我们重新渲染,都会生成_新的_ effect,替换掉之前的。某种意义上讲,effect 更像是渲染结果的一部分 —— 每个 effect “属于”一次特定的渲染。我们将在[本章节后续部分](#explanation-why-effects-run-on-each-update)更清楚地了解这样做的意义。
>提示
>
Expand Down

0 comments on commit 834192b

Please sign in to comment.