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
add
and attach it to Button 1 with anonClick
- Create a function called
subtract
and attach it to Button 2 with anonClick
- Create a state variable called
counter
that increases and decreases with the button clicks
import { useState } from 'react'
// inside the Counter component
const [counter, setCounter] = useState(0)
// counter = 0