|
|
@ -60,8 +60,8 @@ function Counter({initialCount}) { |
|
|
|
<> |
|
|
|
Count: {count} |
|
|
|
<button onClick={() => setCount(initialCount)}>Reset</button> |
|
|
|
<button onClick={() => setCount(prevCount => prevCount + 1)}>+</button> |
|
|
|
<button onClick={() => setCount(prevCount => prevCount - 1)}>-</button> |
|
|
|
<button onClick={() => setCount(prevCount => prevCount + 1)}>+</button> |
|
|
|
</> |
|
|
|
); |
|
|
|
} |
|
|
@ -231,8 +231,8 @@ function Counter() { |
|
|
|
return ( |
|
|
|
<> |
|
|
|
Count: {state.count} |
|
|
|
<button onClick={() => dispatch({type: 'increment'})}>+</button> |
|
|
|
<button onClick={() => dispatch({type: 'decrement'})}>-</button> |
|
|
|
<button onClick={() => dispatch({type: 'increment'})}>+</button> |
|
|
|
</> |
|
|
|
); |
|
|
|
} |
|
|
@ -290,8 +290,8 @@ function Counter({initialCount}) { |
|
|
|
onClick={() => dispatch({type: 'reset', payload: initialCount})}> |
|
|
|
Reset |
|
|
|
</button> |
|
|
|
<button onClick={() => dispatch({type: 'increment'})}>+</button> |
|
|
|
<button onClick={() => dispatch({type: 'decrement'})}>-</button> |
|
|
|
<button onClick={() => dispatch({type: 'increment'})}>+</button> |
|
|
|
</> |
|
|
|
); |
|
|
|
} |
|
|
|