Skip to content

Instantly share code, notes, and snippets.

@Kornil
Last active February 16, 2019 12:24
Show Gist options
  • Save Kornil/9985a6c4f0303ce5956620dafb233390 to your computer and use it in GitHub Desktop.
Save Kornil/9985a6c4f0303ce5956620dafb233390 to your computer and use it in GitHub Desktop.
const Hello = () => {
const [number, updateNumber] = React.useState(0);
return (
<div>
<p>{number}</p>
<button onClick={(prevNum) => updateNumber(prevNum + 1)}>Add 1</button>
<button onClick={(prevNum) => updateNumber(prevNum - 1)}>Remove 1</button>
</div>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment