매개변수에 콜백을 전달

이점

단점 및 주의할 점

function Counter() {
	const [count, setCount] = useState(0);

	const handleIncrement = () => setCount(count + 1);
	const handleAsyncIncrement = () => {
			setTimeout(() => {
					setCount(prev => prev + 1);
					// 최신의 count를 참조하기 때문에 
					// handleIncrement의 결과값 + 1만큼 증가
			
					setCount(count + 1);
					// 핸들러가 실행될 때의 count를 기준으로 
					// handleIncrement가 몇 번 실행되던
					// 핸들러가 시작될 때의 count 값을 1 증가 시킴
			}, 1000);
			set
	}
}
function useState<S>(initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>];