State Hook คือ function ที่ทำให้เราใส่ state เข้าไปใน Function component ได้
import React, { useState } from "react";
function Counter() {
const [counter, setCounter] = useState(0);
return (
<div>
<h1>{counter}</h1>
<button onClick={() => setCounter(counter + 1)}>Add</button>
<button onClick={() => setCounter(counter - 1)}>Subtract</button>
</div>
);
}
export default Counter;