useState 소스 코드 분석 - 2. dispatch 생성
·
React js/react 소스 코드 분석
1. useState의 초기 렌더링: Dispatch가 어떻게 생성될까?function mountState( initialState: (() => S) | S,): [S, Dispatch>] { const hook = mountStateImpl(initialState); const queue = hook.queue; const dispatch: Dispatch> = (dispatchSetState.bind( null, currentlyRenderingFiber, queue, ): any); queue.dispatch = dispatch; return [hook.memoizedState, dispatch];} dispatch 함수는 초기 렌더 시점에 단 한 번 생성된다.dis..