Reset button should set the state back to initialCount (#1327)

This commit is contained in:
Aditya Agarwal
2019-01-10 17:16:33 +05:30
committed by Dan Abramov
parent 92d96a3ca4
commit b5fa1df64f

View File

@@ -54,7 +54,7 @@ function Counter({initialCount}) {
return (
<>
Count: {count}
<button onClick={() => setCount(0)}>Reset</button>
<button onClick={() => setCount(initialCount)}>Reset</button>
<button onClick={() => setCount(prevCount => prevCount + 1)}>+</button>
<button onClick={() => setCount(prevCount => prevCount - 1)}>-</button>
</>