mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 20:23:08 +00:00
Reset button should set the state back to initialCount (#1327)
This commit is contained in:
committed by
Dan Abramov
parent
92d96a3ca4
commit
b5fa1df64f
@@ -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>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user