useReducer로 useState 구현하는 방법
const useStateReducer = (prevState, newState) =>
typeof newState === 'function' ? newState(prevState) : newState;
const useStateInitializer = initialValue =>
typeof initialValue === 'function' ? initialValue() : initialValue;
function useState(initialValue) {
return React.useReducer(useStateReducer, initialValue, useStateInitializer);
}But Kent.. why기
Last updated
Was this helpful?