Skip to content

Commit dbe7193

Browse files
author
Jianping Song
committed
docs(cn): update translation for content/docs/legacy-context.md
1 parent 10aa54b commit dbe7193

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

content/docs/legacy-context.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ const BasicExample = () => (
158158
159159
只要 `contextTypes` 被定义为函数的一个属性,函数组件也能够引用 `context`。下面的代码展示了一个函数组件写法的 `Button` 组件。
160160

161-
<br/>
162-
163161
```javascript
164162
import PropTypes from 'prop-types';
165163

@@ -177,7 +175,7 @@ Button.contextTypes = {color: PropTypes.string};
177175
178176
不要这样做。
179177

180-
React 有一个 API 可以更新 context,但它基本上是坏的,你不应该使用它。
178+
React 有一个 API 可以更新 context,但它基本上是不靠谱的,你不应该使用它。
181179

182180
当 state 或者 props 改变的时候,`getChildContext` 函数就会被调用。为了更新 context 里的数据,使用 `this.setState` 触发当前 state 的更新。这样会产生一个新的 context 并且子组件会接收到变化。
183181

@@ -216,4 +214,4 @@ MediaQuery.childContextTypes = {
216214
};
217215
```
218216

219-
问题是,如果组件提供的一个 context 发生了变化,而中间父组件的 `shouldComponentUpdate` 返回 `false`,那么使用到该值的后代组件不会进行更新。使用了 context 的组件则完全失控,所以基本上没有办法能够可靠的更新 context。[这篇博客文章](https://medium.com/@mweststrate/how-to-safely-use-react-context-b7e343eff076)很好地解释了为什么这是一个问题,以及你该如何规避它。
217+
问题是,如果组件提供的一个 context 发生了变化,而中间父组件的 `shouldComponentUpdate` 返回 `false`,那么使用到该值的后代组件不会进行更新。使用了 context 的组件则完全失控,所以基本上没有办法能够可靠的更新 context。[这篇博客文章](https://medium.com/@mweststrate/how-to-safely-use-react-context-b7e343eff076)很好地解释了为何会出现此类问题,以及你该如何规避它。

0 commit comments

Comments
 (0)