Created
February 5, 2020 22:20
-
-
Save basarat/500b5b8d206b33f91550f29c251421a9 to your computer and use it in GitHub Desktop.
React useReuse pattern
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
function Counter() { | |
// Some hooks the component needs | |
const [count, setCount] = useState(0); | |
// The rendering of the component | |
return ( | |
<div> | |
<p>You clicked {count} times</p> | |
<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