Last active
November 3, 2018 18:10
-
-
Save jhonnymichel/556fe25b095538ae4c216a437eccf700 to your computer and use it in GitHub Desktop.
Hookstore Snippet 1: useState
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'; | |
function StatefulHello() { | |
const [timesClicked, updateTimesClicked] = useState(0); | |
return ( | |
<div> | |
<h1>Hello, world!</h1> | |
<h2>The button inside this component was clicked {timesClicked} times</h2> | |
<button | |
type="button" | |
onClick={() => updateTimesClicked(timesClicked + 1)} | |
> | |
Update | |
</button> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment