Skip to content

Commit d7fabec

Browse files
committed
update after comment
1 parent 25edb87 commit d7fabec

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

content/blog/2020-02-26-react-v16.13.0.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ redirect_from:
55
- "blog/2020/03/02/react-v16.13.0.html"
66
---
77

8-
我们今天发布了 React 16.13.0。它包含了 bug 修复和新的弃用警告,来帮助准备未来的主要版本
8+
今天我们发布了 React 16.13.0。此版本修复了部分 bug 并添加了新的弃用警告,以助力接下来的主要版本
99

1010
## 新的警告 {#new-warnings}
1111

1212
### Render 期间更新的警告 {#warnings-for-some-updates-during-render}
1313

14-
一个 React 组件不应该在 render 期间对其他组件造成副作用影响
14+
React 组件不应在 render 期间对其他组件产生副作用
1515

16-
在 render 期间调用 `setState` 是被支持的,但是 [仅仅适用于*同一个 component*](/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops)如果你在另一个 component render 期间调用 `setState`,现在你将会看到一条警告。
16+
在 render 期间调用 `setState` 是被支持的,但是 [仅仅适用于*同一个组件*](/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops)如果你在另一个组件 render 期间调用 `setState`,现在你将会看到一条警告。
1717

1818
```
1919
Warning: Cannot update a component from inside the function body of a different component.
@@ -34,13 +34,13 @@ Warning: Cannot update a component from inside the function body of a different
3434
</div>
3535
```
3636

37-
你可能期待这个 `<div>` 总是拥有红色背景,不论 `toggle` 的值是什么。然而,在 `true``false`之间交替使用`toggle`时,背景色开始是 `red`,然后在 `transparent``blue`之间交替, [像你能在这个 demo 中看到的](https://codesandbox.io/s/suspicious-sunset-g3jub)
37+
你可能期待这个 `<div>` 总是拥有红色背景,不论 `toggle` 的值是什么。然而,在 `true``false`之间交替使用`toggle`时,背景色开始是 `red`,然后在 `transparent``blue`之间交替, [正如你能在这个 demo 中看到的](https://codesandbox.io/s/suspicious-sunset-g3jub)
3838

39-
**React 现在检测到冲突的样式规则并记录警告**要解决此问题,请不要在 `style` 属性中混合使用同一CSS属性的简写和全写版本。
39+
**React 现在检测到冲突的样式规则并打印出警告**要解决此问题,请不要在 `style` 属性中混合使用同一CSS属性的简写和全写版本。
4040

41-
### 某些不推荐使用的字符串 ref 的警告 {#warnings-for-some-deprecated-string-refs}
41+
### 某些废弃字符串 ref 的警告 {#warnings-for-some-deprecated-string-refs}
4242

43-
[字符串 ref 是旧版的 API](/docs/refs-and-the-dom.html#legacy-api-string-refs) 这是不可取的,将来将被弃用:
43+
[字符串 ref 是过时的 API](/docs/refs-and-the-dom.html#legacy-api-string-refs) 这是不可取的,将来将被弃用:
4444

4545
```js
4646
<Button ref="myRef" />
@@ -73,9 +73,9 @@ class ClassParent extends React.Component {
7373
}
7474
```
7575

76-
这样的代码通常暗含 bug。(你可能希望ref在 `ClassParent` 上可用,但是它被放在 `ClassWithRenderProp` 上)。
76+
这样的代码通常暗含 bug。(你可能希望 ref 在 `ClassParent` 上可用,但是它被放在 `ClassWithRenderProp` 上)。
7777

78-
**你很可能没有这样的代码**如果是故意的,请将其转换为[`React.createRef()`](/docs/refs-and-the-dom.html#creating-refs)
78+
**你很可能没有这样的代码**如果是有意为之,请将其转换为 [`React.createRef()`](/docs/refs-and-the-dom.html#creating-refs)
7979

8080
```jsx
8181
class ClassWithRenderProp extends React.Component {
@@ -101,15 +101,15 @@ class ClassParent extends React.Component {
101101

102102
> Note
103103
>
104-
> 要查看此警告,你需要在你的 Babel plugins 中安装[babel-plugin-transform-react-jsx-self](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx-self)。它必须 _仅仅_ 在开发模式下启用。
104+
> 要查看此警告,你需要在你的 Babel plugins 中安装 [babel-plugin-transform-react-jsx-self](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx-self)。它必须 _仅仅_ 在开发模式下启用。
105105
>
106-
> 如果你使用 Create React App 或者用 babel 7 + 预置了 React,那么默认情况下已经安装了这个插件。
106+
> 如果你使用 Create React App 或者用 babel 7+ 的 React preset,那么默认情况下已经安装了这个插件。
107107
108108
### 弃用 `React.createFactory` {#deprecating-reactcreatefactory}
109109

110110
[`React.createFactory`](/docs/react-api.html#createfactory)为 React 创建一个帮助器元素。此版本向该方法添加了一个弃用警告。它将在未来的主要版本中删除。
111111

112-
替换的用法 `React.createFactory` 用普通的 JSX 。或者可以复制并粘贴此单行辅助对象或将其发布为库:
112+
`React.createFactory` 替换为普通的 JSX 。或者可以复制并粘贴此单行辅助对象或将其发布为库:
113113

114114
```jsx
115115
let createFactory = type => React.createElement.bind(null, type);
@@ -125,15 +125,15 @@ let createFactory = type => React.createElement.bind(null, type);
125125

126126
## 其他改进 {#other-improvements}
127127

128-
### Hydration 过程中 Component 堆栈的警告 {#component-stacks-in-hydration-warnings}
128+
### Hydration 过程中组件堆栈的警告 {#component-stacks-in-hydration-warnings}
129129

130-
React 将 Component 堆栈添加到其开发警告中,使开发人员能够隔离 bug 并调试他们的程序。此版本将 Component 堆栈添加到许多以前没有的开发警告中。举个例子,考虑一下以前版本中的 hydration 警告:
130+
React 将组件堆栈添加到其开发警告中,使开发人员能够隔离 bug 并调试他们的程序。此版本将组件堆栈添加到许多以前没有的开发警告中。举个例子,考虑一下以前版本中的 hydration 警告:
131131

132132
![控制台警告的屏幕截图,简单地说明 hydration 不匹配的性质:"Warning: Expected server HTML to contain a matching div in div."](../images/blog/react-v16.13.0/hydration-warning-before.png)
133133

134-
虽然它指出了代码中的一个错误,但不清楚错误在哪里存在,以及下一步该怎么做。此版本向此警告添加了一个 Component 堆栈,使其看起来如下所示:
134+
虽然它指出了代码中的一个错误,但不清楚错误在哪里存在,以及下一步该怎么做。此版本向此警告添加了一个组件堆栈,使其看起来如下所示:
135135

136-
![控制台警告的屏幕截图,说明 hydration 不匹配的性质,但也包括 Component 堆栈:"Warning: Expected server HTML to contain a matching div in div, in div (at pages/index.js:4)..."](../images/blog/react-v16.13.0/hydration-warning-after.png)
136+
![控制台警告的屏幕截图,说明 hydration 不匹配的性质,但也包括组件堆栈:"Warning: Expected server HTML to contain a matching div in div, in div (at pages/index.js:4)..."](../images/blog/react-v16.13.0/hydration-warning-after.png)
137137

138138
这样可以清楚地看出问题所在,并让你更快地找到并修复错误。
139139

@@ -143,7 +143,7 @@ React 将 Component 堆栈添加到其开发警告中,使开发人员能够隔
143143

144144
- 在严格的开发模式下,React 调用生命周期方法两次,以清除任何可能不需要的副作用。此版本将此行为添加到 `shouldComponentUpdate` 中。这不会影响大多数代码,除非在 `shouldComponentUpdate` 中有副作用。要解决此问题,请将具有副作用的代码移到 `componentDidUpdate` 中。
145145

146-
- 在严格开发模式下,使用遗留上下文 API 的警告不包括触发警告的 Component 堆栈。此版本将丢失的堆栈添加到警告中。
146+
- 在严格开发模式下,使用遗留上下文 API 的警告不包括触发警告的组件堆栈。此版本将丢失的堆栈添加到警告中。
147147

148148
- `onMouseEnter` 现在在被禁用的 `<button>` 对象上不能被触发。
149149

0 commit comments

Comments
 (0)