Skip to content

Commit ad67e2f

Browse files
fix: wording
1 parent a118286 commit ad67e2f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

content/docs/state-and-lifecycle.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ class Clock extends React.Component {
248248

249249
注意我們是如何正確的在 `this` 保存 timer ID。
250250

251-
雖然 `this.props` 是由 React 本身設定的,而且 `this.state` 具有特殊的意義,如果你需要儲存一些不相關於 data flow 的內容(像是 timer ID),你可以自由的手動加入。
251+
雖然 `this.props` 是由 React 本身設定的,而且 `this.state` 具有特殊的意義,如果你需要儲存一些不相關於資料流的內容(像是 timer ID),你可以自由的手動加入。
252252

253253
我們將會在 `componentWillUnmount()` 生命週期方法內移除 timer:
254254

@@ -327,18 +327,18 @@ ReactDOM.render(
327327
例如,這將不會重新 render component:
328328

329329
```js
330-
// Wrong
330+
// 錯誤
331331
this.state.comment = 'Hello';
332332
```
333333

334334
相反的,使用 `setState()`
335335

336336
```js
337-
// Correct
337+
// 正確
338338
this.setState({comment: 'Hello'});
339339
```
340340

341-
你唯一可以指定 `this.state` 值的地方是在 construcotr
341+
你唯一可以指定 `this.state` 值的地方是在 constructor
342342

343343
### State 的更新可能是非同步的 {#state-updates-may-be-asynchronous}
344344

@@ -349,7 +349,7 @@ React 可以將多個 `setState()` 呼叫批次處理為單一的更新,以提
349349
例如,這個程式碼可能無法更新 counter:
350350

351351
```js
352-
// Wrong
352+
// 錯誤
353353
this.setState({
354354
counter: this.state.counter + this.props.increment,
355355
});
@@ -358,7 +358,7 @@ this.setState({
358358
要修正這個問題,使用第二種形式的 `setState()`,它接受一個 function 而不是一個 object。Function 將接收先前的 state 作為第一個參數,並且將更新的 props 作為第二個參數:
359359

360360
```js
361-
// Correct
361+
// 正確
362362
this.setState((state, props) => ({
363363
counter: state.counter + props.increment
364364
}));
@@ -367,7 +367,7 @@ this.setState((state, props) => ({
367367
在上面我們使用 [arrow function](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions),但它也可以適用於正常的 function:
368368

369369
```js
370-
// Correct
370+
// 正確
371371
this.setState(function(state, props) {
372372
return {
373373
counter: state.counter + props.increment
@@ -411,7 +411,7 @@ this.setState(function(state, props) {
411411

412412
這個 merge 是 shallow 的,所以 `this.setState({comments})` 保持 `this.state.posts` 的完整,但它完全取代了 `this.state.comments`
413413

414-
## 資料流向下 {#the-data-flows-down}
414+
## 向下資料流 {#the-data-flows-down}
415415

416416
Parent 和 child component 不會知道某個 component 是 stateful 或 stateless 的 component,而且它們不在意它是透過 function 或是 class 被定義的。
417417

0 commit comments

Comments
 (0)