Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b705ac4

Browse files
author
我和胖虎五五开
committedMar 20, 2019
fix
1 parent 0d1b17d commit b705ac4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed
 

‎content/docs/reference-react-component.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Welcome extends React.Component {
3131

3232
`React.Component` 的子类中有个必须定义的 [`render()`](#render) 函数。本章节介绍其他方法均为可选。
3333

34-
**我们极其反对你创建自己的组件基类** 在 React 组件中,[代码重用的主要方式是组合而不是继承](/docs/composition-vs-inheritance.html)
34+
**我们强烈建议你不要创建自己的组件基类** 在 React 组件中,[代码重用的主要方式是组合而不是继承](/docs/composition-vs-inheritance.html)
3535

3636
>注意:
3737
>
@@ -262,7 +262,7 @@ shouldComponentUpdate(nextProps, nextState)
262262

263263
如果你一定要手动编写此函数,可以将 `this.props``nextProps ` 以及 `this.state``nextState` 进行比较,并返回 `false` 以告知 React 可以跳过更新。请注意,返回 `false` 并不会阻止子组件在 state 更改时重新渲染。
264264

265-
我们不建议在 `shouldComponentUpdate()` 中进行深层比较或使用 `JSON.stringify()`。这样非常影响效率,且会损害性能
265+
我们不建议在 `shouldComponentUpdate()` 中进行深层比较或使用 `JSON.stringify()`。这样非常影响效率,且会损害性能
266266

267267
目前,如果 `shouldComponentUpdate()` 返回 `false`,则不会调用 [`UNSAFE_componentWillUpdate()`](#unsafe_componentwillupdate)[`render()`](#render)[`componentDidUpdate()`](#componentdidupdate)。后续版本,React 可能会将 `shouldComponentUpdate` 视为提示而不是严格的指令,并且,当返回 `false` 时,仍可能导致组件重新渲染。
268268

@@ -343,13 +343,13 @@ class ErrorBoundary extends React.Component {
343343
}
344344
345345
static getDerivedStateFromError(error) {
346-
// 更新 state 使下一次渲染可以显降级UI
346+
// 更新 state 使下一次渲染可以显降级 UI
347347
return { hasError: true };
348348
}
349349
350350
render() {
351351
if (this.state.hasError) {
352-
// 你可以渲染任何自定义的降级UI
352+
// 你可以渲染任何自定义的降级 UI
353353
return <h1>Something went wrong.</h1>;
354354
}
355355
@@ -389,7 +389,7 @@ class ErrorBoundary extends React.Component {
389389
}
390390
391391
static getDerivedStateFromError(error) {
392-
// 更新 state 使下一次渲染可以显示降级UI
392+
// 更新 state 使下一次渲染可以显示降级 UI
393393
return { hasError: true };
394394
}
395395
@@ -404,7 +404,7 @@ class ErrorBoundary extends React.Component {
404404
405405
render() {
406406
if (this.state.hasError) {
407-
// 你可以渲染任何自定义的降级UI
407+
// 你可以渲染任何自定义的降级 UI
408408
return <h1>Something went wrong.</h1>;
409409
}
410410

0 commit comments

Comments
 (0)
Please sign in to comment.