Skip to content

Instantly share code, notes, and snippets.

@basarat
Created February 5, 2020 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save basarat/500b5b8d206b33f91550f29c251421a9 to your computer and use it in GitHub Desktop.
Save basarat/500b5b8d206b33f91550f29c251421a9 to your computer and use it in GitHub Desktop.
React useReuse pattern
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