<aside> <img src="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/f765100f-b481-437e-b531-5aae8d9bc5fe/1200px-React-icon.svg.png" alt="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/f765100f-b481-437e-b531-5aae8d9bc5fe/1200px-React-icon.svg.png" width="40px" /> Velopert's Modern React
</aside>
목차
-useState로 함수형 컴포넌트에서 state 관리하기
Hook 사용 시 지켜야 하는 규칙
useState로 함수형 컴포넌트에서 state 관리하기
import { useState } from 'react'
Counter.jsx
function Counter() {
const [number, setNumber] = useState(0);
const onIncrease = () => {
setNumber((prev) => prev + 1);
}
const onDecrease = () => {
setNumber(number - 1);
}
}