Skip to content

Instantly share code, notes, and snippets.

@HuyAms
Created November 11, 2019 08:56
Show Gist options
  • Save HuyAms/0a66178ed30c408f867ab1c4b0c14aa7 to your computer and use it in GitHub Desktop.
Save HuyAms/0a66178ed30c408f867ab1c4b0c14aa7 to your computer and use it in GitHub Desktop.
const App = () => {
const [count1, setCount1] = React.useState(0)
const [count2, setCount2] = React.useState(0)
const increaseCounter1 = () => {
setCount1(count1 => count1 + 1)
}
const increaseCounter2 = () => {
setCount1(count2 => count1 + 1)
}
return (
<>
<Counter value={count1} onClick={increaseCounter1}>Counter 1</Counter>
<Counter value={count2} onClick={increaseCounter2}>Coutner 2</Counter>
</>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment