Frames

useState sample

0
1import React, { useState } from "react";
2
3
4const Counter = () => {
5 const [counter, setCounter] = useState(0)
6
7 return (
8 <div>
9 <h2>{counter}</h2>
10 <button className="incrementButton" onClick={() => setCounter((count) => count + 1) }> +1 </button>
11 <button className="decrementButton" onClick={() => setCounter((count) => count - 1) }> -1 </button>
12 </div>
13 );
14}
15export default Counter;