質問編集履歴
1
リセットしたいのにStopと記述しており、紛らわしいためStopをResetに変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,12 +8,12 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
```
|
11
|
-
const
|
11
|
+
const countReset = ()=> setCount(count==0);
|
12
12
|
|
13
13
|
```
|
14
14
|
とreturn後に表示させる
|
15
15
|
```
|
16
|
-
<button onClick={
|
16
|
+
<button onClick={countReset}>リセット!</button>
|
17
17
|
|
18
18
|
```
|
19
19
|
を用意し、実行しましたが、
|
@@ -40,14 +40,14 @@
|
|
40
40
|
const [ count, setCount ] = useState(0);
|
41
41
|
const countUp = ()=> setCount(count+1);
|
42
42
|
const countDown = ()=> setCount(count-1);
|
43
|
-
const
|
43
|
+
const countReset = ()=> setCount(count==0);
|
44
44
|
return(
|
45
45
|
<>
|
46
46
|
<h2>カウントチャレンジ</h2>
|
47
47
|
<p>カウント: {count}</p>
|
48
48
|
<button onClick={countUp}>+</button>
|
49
49
|
<button onClick={countDown} style={{marginRight:"10px"}}>-</button>
|
50
|
-
<button onClick={
|
50
|
+
<button onClick={countReset}>リセット!</button>
|
51
51
|
</>
|
52
52
|
)
|
53
53
|
}
|