Created
October 31, 2018 16:37
-
-
Save theham3d/f040d218c46a5961fb37b3ffc3aa896d to your computer and use it in GitHub Desktop.
useStateExample
This file contains 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
import React , { useState } from 'react'; | |
const MyCounter = props => { | |
const [count, setCount] = useState(0); | |
//you can use useState as much as you want | |
return ( | |
<div> | |
<h1>{count}</h1> | |
<button onClick={() => setCount(count + 1)}>Click me</button> | |
</div> | |
); | |
} | |
export default MyCounter; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment