回答編集履歴

3

質問上のコードとReact公式サイト上のコードをあわせました

2017/11/24 10:53

投稿

HayatoKamono
HayatoKamono

スコア2415

test CHANGED
@@ -36,7 +36,7 @@
36
36
 
37
37
  this.setState((prevState, props) => ({
38
38
 
39
- count: prevState.counter + 1
39
+ count: prevState.count + 1
40
40
 
41
41
  });
42
42
 

2

リンク先を参照ページの該当箇所アンカーに変更

2017/11/24 10:53

投稿

HayatoKamono
HayatoKamono

スコア2415

test CHANGED
@@ -8,9 +8,9 @@
8
8
 
9
9
 
10
10
 
11
- [https://reactjs.org/docs/state-and-lifecycle.html
11
+ [https://reactjs.org/docs/state-and-lifecycle.html#state-updates-may-be-asynchronous
12
12
 
13
- ](https://reactjs.org/docs/state-and-lifecycle.html)
13
+ ](https://reactjs.org/docs/state-and-lifecycle.html#state-updates-may-be-asynchronous)
14
14
 
15
15
 
16
16
 

1

Because this.props and this.state may be updated asynchronously, you should not rely on their values

2017/11/24 10:37

投稿

HayatoKamono
HayatoKamono

スコア2415

test CHANGED
@@ -4,9 +4,15 @@
4
4
 
5
5
  # 参考
6
6
 
7
+ > Because this.props and this.state may be updated asynchronously, you should not rely on their values for calculating the next state.
8
+
9
+
10
+
7
11
  [https://reactjs.org/docs/state-and-lifecycle.html
8
12
 
9
13
  ](https://reactjs.org/docs/state-and-lifecycle.html)
14
+
15
+
10
16
 
11
17
  # Wrong
12
18