質問編集履歴

1

エラーを追記

2018/09/27 04:23

投稿

hiroakitajima
hiroakitajima

スコア27

test CHANGED
File without changes
test CHANGED
@@ -31,3 +31,37 @@
31
31
  });
32
32
 
33
33
  ```
34
+
35
+ ```jsx
36
+
37
+ //TypeError: this.setState is not a functionになる
38
+
39
+ let map = document.getElementById("map");
40
+
41
+ var lastInnerWidth = map.clientWidth;
42
+
43
+ window.addEventListener("resize", function() {
44
+
45
+ if (lastInnerWidth != map.clientWidth) {
46
+
47
+ lastInnerWidth = map.clientWidth;
48
+
49
+ }
50
+
51
+ let boxSize = (lastInnerWidth - 100) / 5;
52
+
53
+ this.setState({
54
+
55
+ mapWidth: lastInnerWidth,
56
+
57
+ boxWidth: boxSize
58
+
59
+ });
60
+
61
+ console.log(this.state.mapWidth);
62
+
63
+ console.log(this.state.boxWidth);
64
+
65
+ });
66
+
67
+ ```