-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
docs(cn): translate content/docs/legacy-context.md into Chinese #370
Conversation
Deploy preview for zh-hans-reactjs ready! Built with commit dbe7193 |
content/docs/legacy-context.md
Outdated
Function components are also able to reference `context` if `contextTypes` is defined as a property of the function. The following code shows a `Button` component written as a function component. | ||
只要 `contextTypes` 被定义为函数的一个属性,函数组件也能够引用 `context`。下面的代码展示了一个函数组件写法的 `Button` 组件。 | ||
|
||
<br/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<br/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
content/docs/legacy-context.md
Outdated
@@ -214,4 +216,4 @@ MediaQuery.childContextTypes = { | |||
}; | |||
``` | |||
|
|||
The problem is, if a context value provided by component changes, descendants that use that value won't update if an intermediate parent returns `false` from `shouldComponentUpdate`. This is totally out of control of the components using context, so there's basically no way to reliably update the context. [This blog post](https://medium.com/@mweststrate/how-to-safely-use-react-context-b7e343eff076) has a good explanation of why this is a problem and how you might get around it. | |||
问题是,如果组件提供的一个 context 发生了变化,而中间父组件的 `shouldComponentUpdate` 返回 `false`,那么使用到该值的后代组件不会进行更新。使用了 context 的组件则完全失控,所以基本上没有办法能够可靠的更新 context。[这篇博客文章](https://medium.com/@mweststrate/how-to-safely-use-react-context-b7e343eff076)很好地解释了为什么这是一个问题,以及你该如何规避它。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
问题是,如果组件提供的一个 context 发生了变化,而中间父组件的 `shouldComponentUpdate` 返回 `false`,那么使用到该值的后代组件不会进行更新。使用了 context 的组件则完全失控,所以基本上没有办法能够可靠的更新 context。[这篇博客文章](https://medium.com/@mweststrate/how-to-safely-use-react-context-b7e343eff076)很好地解释了为什么这是一个问题,以及你该如何规避它。 | |
问题是,如果组件提供的一个 context 发生了变化,而中间父组件的 `shouldComponentUpdate` 返回 `false`,那么使用到该值的后代组件不会进行更新。使用了 context 的组件则完全失控,所以基本上没有办法能够可靠的更新 context。[这篇博客文章](https://medium.com/@mweststrate/how-to-safely-use-react-context-b7e343eff076)很好地解释了为何会出现此类问题,以及你该如何规避它。 |
content/docs/legacy-context.md
Outdated
|
||
React has an API to update context, but it is fundamentally broken and you should not use it. | ||
React 有一个 API 可以更新 context,但它基本上是坏的,你不应该使用它。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React 有一个 API 可以更新 context,但它基本上是坏的,你不应该使用它。 | |
React 有一个 API 可以更新 context,但它基本上是不靠谱的,你不应该使用它。 |
@yes1am 修改下,大体没啥问题 |
translate content/docs/legacy-context.md into Chinese