Use the following code block to get started:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
function GetCount() {
  const [count, setCount] = useState(1);

  const incrementCounter = () => {
    setCount(count+1)
  }
  const decrementCounter = () => {
    if (count>1) setCount(count-1)
  }

  return <div className="_counterWrapper">
    <span className="_dec" onClick={() => decrementCounter()}>-</span>
    <span className="_val">{count}</span>
    <span className="_inc" onClick={() => incrementCounter()}>+</span>
  </div>
}

Then in your HTML code, add it like this:

1
<GetCount />