Reference: only use tutorial that use functional components
// function Counter (){}
// const Counter = () => {}
// DO NOT USE CLASS COMPONENTS
// class Counter
// this.setState
- Create two buttons.
- Button 1 - click to add
- Button 2 - click to subtract
- Create a function called
addand attach it to Button 1 with anonClick - Create a function called
subtractand attach it to Button 2 with anonClick - Create a state variable called
counterthat increases and decreases with the button clicks
import { useState } from 'react'
// inside the Counter component
const [counter, setCounter] = useState(0)
// counter = 0