Created
November 5, 2018 15:26
-
-
Save chentsulin/a045c49434a88f7974c72eabed3157d9 to your computer and use it in GitHub Desktop.
counter hooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Counter = ({ defaultValue }) => { | |
const [count, setCount] = useState(defaultValue); | |
const handlePlusOne = () => { | |
setCount(count + 1); | |
} | |
return ( | |
<> | |
<div>{count}</div> | |
<button onClick={handlePlusOne}>+</button> | |
</> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment