回答編集履歴

1

追記

2018/07/11 06:49

投稿

og24715
og24715

スコア832

test CHANGED
@@ -6,7 +6,9 @@
6
6
 
7
7
 
8
8
 
9
- click() メソッド中の this Appラスをさないので以下のようにしてくださ
9
+ click() メソッド中の this は恐らく Window オブジェトと差していると思います。
10
+
11
+ App コンポーネントのインスタンスそのものを差すようにするには以下のようにしてください。
10
12
 
11
13
 
12
14
 
@@ -15,3 +17,13 @@
15
17
  <h1 onClick={this.click.bind(this)}>Hello World</h1>
16
18
 
17
19
  ```
20
+
21
+
22
+
23
+ または、またはメソッドをアロー関数で定義することで避けられます。
24
+
25
+
26
+
27
+ [reactjs - this.setState is undefined - Stack Overflow](https://stackoverflow.com/questions/39210971/this-setstate-is-undefined)
28
+
29
+ [javascript - Unable to access React instance (this) inside event handler - Stack Overflow](https://stackoverflow.com/questions/29577977/unable-to-access-react-instance-this-inside-event-handler)