回答編集履歴
3
質問上のコードとReact公式サイト上のコードをあわせました
test
CHANGED
@@ -36,7 +36,7 @@
|
|
36
36
|
|
37
37
|
this.setState((prevState, props) => ({
|
38
38
|
|
39
|
-
count: prevState.count
|
39
|
+
count: prevState.count + 1
|
40
40
|
|
41
41
|
});
|
42
42
|
|
2
リンク先を参照ページの該当箇所アンカーに変更
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
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
|
|