@@ -31,7 +31,7 @@ class Welcome extends React.Component {
31
31
32
32
在 ` React.Component ` 的子类中有个必须定义的 [ ` render() ` ] ( #render ) 函数。本章节介绍其他方法均为可选。
33
33
34
- ** 我们极其反对你创建自己的组件基类 。** 在 React 组件中,[ 代码重用的主要方式是组合而不是继承] ( /docs/composition-vs-inheritance.html ) 。
34
+ ** 我们强烈建议你不要创建自己的组件基类 。** 在 React 组件中,[ 代码重用的主要方式是组合而不是继承] ( /docs/composition-vs-inheritance.html ) 。
35
35
36
36
> 注意:
37
37
>
@@ -262,7 +262,7 @@ shouldComponentUpdate(nextProps, nextState)
262
262
263
263
如果你一定要手动编写此函数,可以将 ` this.props ` 与 ` nextProps ` 以及 ` this.state ` 与` nextState ` 进行比较,并返回 ` false ` 以告知 React 可以跳过更新。请注意,返回 ` false ` 并不会阻止子组件在 state 更改时重新渲染。
264
264
265
- 我们不建议在 ` shouldComponentUpdate() ` 中进行深层比较或使用 ` JSON.stringify() ` 。这样非常影响效率,且会损害性能
265
+ 我们不建议在 ` shouldComponentUpdate() ` 中进行深层比较或使用 ` JSON.stringify() ` 。这样非常影响效率,且会损害性能。
266
266
267
267
目前,如果 ` shouldComponentUpdate() ` 返回 ` false ` ,则不会调用 [ ` UNSAFE_componentWillUpdate() ` ] ( #unsafe_componentwillupdate ) ,[ ` render() ` ] ( #render ) 和 [ ` componentDidUpdate() ` ] ( #componentdidupdate ) 。后续版本,React 可能会将 ` shouldComponentUpdate ` 视为提示而不是严格的指令,并且,当返回 ` false ` 时,仍可能导致组件重新渲染。
268
268
@@ -343,13 +343,13 @@ class ErrorBoundary extends React.Component {
343
343
}
344
344
345
345
static getDerivedStateFromError(error) {
346
- // 更新 state 使下一次渲染可以显降级UI
346
+ // 更新 state 使下一次渲染可以显降级 UI
347
347
return { hasError: true };
348
348
}
349
349
350
350
render() {
351
351
if (this.state.hasError) {
352
- // 你可以渲染任何自定义的降级UI
352
+ // 你可以渲染任何自定义的降级 UI
353
353
return <h1>Something went wrong.</h1>;
354
354
}
355
355
@@ -389,7 +389,7 @@ class ErrorBoundary extends React.Component {
389
389
}
390
390
391
391
static getDerivedStateFromError(error) {
392
- // 更新 state 使下一次渲染可以显示降级UI
392
+ // 更新 state 使下一次渲染可以显示降级 UI
393
393
return { hasError: true };
394
394
}
395
395
@@ -404,7 +404,7 @@ class ErrorBoundary extends React.Component {
404
404
405
405
render() {
406
406
if (this.state.hasError) {
407
- // 你可以渲染任何自定义的降级UI
407
+ // 你可以渲染任何自定义的降级 UI
408
408
return <h1>Something went wrong.</h1>;
409
409
}
410
410
0 commit comments