質問編集履歴
2
誤字修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -320,7 +320,7 @@
|
|
320
320
|
|
321
321
|
|
322
322
|
|
323
|
-
・localhostの表示
|
323
|
+
・http://localhost:3000の表示
|
324
324
|
|
325
325
|
```
|
326
326
|
|
1
追記:{count}の括弧{}を外した場合
test
CHANGED
File without changes
|
test
CHANGED
@@ -267,3 +267,81 @@
|
|
267
267
|
}
|
268
268
|
|
269
269
|
```
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
### 追記:{count}の括弧{}を外した場合
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
◆修正後のコード
|
278
|
+
|
279
|
+
```
|
280
|
+
|
281
|
+
useEffect(() => {
|
282
|
+
|
283
|
+
const interval = setInterval(() => {
|
284
|
+
|
285
|
+
setCount(c => c + 1);
|
286
|
+
|
287
|
+
squares[items[count].position] = items[count].value;
|
288
|
+
|
289
|
+
}, 1000);
|
290
|
+
|
291
|
+
return () => clearInterval(interval);
|
292
|
+
|
293
|
+
}, []);
|
294
|
+
|
295
|
+
```
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
◆エラー内容
|
300
|
+
|
301
|
+
・コンソール
|
302
|
+
|
303
|
+
```
|
304
|
+
|
305
|
+
Compiled with warnings.
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
src/components/Borad.tsx
|
310
|
+
|
311
|
+
Line 30:6: React Hook useEffect has missing dependencies: 'count', 'items', and 'squares'. Either include them or remove the dependency array react-hooks/exhaustive-deps
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
Search for the keywords to learn more about each warning.
|
316
|
+
|
317
|
+
To ignore, add // eslint-disable-next-line to the line before.
|
318
|
+
|
319
|
+
```
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
・localhostの表示
|
324
|
+
|
325
|
+
```
|
326
|
+
|
327
|
+
TypeError: Cannot read property 'position' of undefined
|
328
|
+
|
329
|
+
(anonymous function)
|
330
|
+
|
331
|
+
src/components/Borad.tsx:27
|
332
|
+
|
333
|
+
24 | useEffect(() => {
|
334
|
+
|
335
|
+
25 | const interval = setInterval(() => {
|
336
|
+
|
337
|
+
26 | setCount(c => c + 1);
|
338
|
+
|
339
|
+
> 27 | squares[items[count].position] = items[count].value;
|
340
|
+
|
341
|
+
| ^ 28 | }, 1000);
|
342
|
+
|
343
|
+
29 | return () => clearInterval(interval);
|
344
|
+
|
345
|
+
30 | }, []);
|
346
|
+
|
347
|
+
```
|