index를 통해 관리하고 있다. 그래서 조건문이나 loop문 등에 포함되면 순서가 보장되지 않기 떄문에이 작동하는 방식 hook 관련 린트에러가 발생한다.
Hook 바닥부터 순차적 작성해보기
function getAdd() {
let _count = 0;
return function() {
const addCount = () => (_count += 1);
// const state = _count;
const getCount = () => _count;
const printCount = () => console.log(_count);
return {
// count,
getCount,
addCount,
printCount,
};
};
}
const addEnv1 = getAdd();
const add1 = addEnv1();
add1.printCount();
add1.addCount();
add1.addCount();
add1.printCount();
console.log(add1.getCount());useState 만들기
컴포넌트에 붙여보기
훅 여러개 사용해보기
useEffect 구현하기
Summary
Last updated
Was this helpful?