Created
January 18, 2019 10:03
-
-
Save cbrannen9a/09293b5892a3b9d0fa2bcfc466ce9115 to your computer and use it in GitHub Desktop.
React hooks useState example
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
export const UseState = () => { | |
//Declare state value of count and setCount function to update | |
//set the initial value of count as 0 | |
const [count, setCount] = useState(0); | |
//setCount function | |
return ( | |
<div className='content'> | |
<h4>UseState</h4> | |
<p>You clicked {count} times</p> | |
<button | |
className='button' | |
onClick={() => setCount(count + 1)}> | |
Click me | |
</button> | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment