Skip to content

Instantly share code, notes, and snippets.

@ayoayco
Created April 19, 2023 06:40
Show Gist options
  • Save ayoayco/f42a111a5bd9bfcf0ef93770c6cb304a to your computer and use it in GitHub Desktop.
Save ayoayco/f42a111a5bd9bfcf0ef93770c6cb304a to your computer and use it in GitHub Desktop.
Counter component
import { useState } from 'react'
const Counter = () => {
const [state, setState] = useState(0)
return (
<>
<h1>Counter</h1>
<p>{state}</p>
<button onClick={() => setState(state + 1)}>+</button>
<button onClick={() => setState(state - 1)}>-</button>
</>
)
}
export default Counter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment