Today rtolzo Learned
Github
Tags
Github
Tags
  • Topics
    • Typescript
    • Git
  • TIL
    • 2022 TIL
    • 2023 TIL
    • 2024 TIL

React Hook 동작 방식

의문

실제 코드를 짤 때 hook은 컴포넌트 내부에 있다. 정확히 말하면 함수 내부에 있음.
hook을 호출할 때 컴포넌트에 관련된 정보가 없음에도 해당 상태는 컴포넌트와 어떻게 매핑이 되는가?? 내부 자료구조가 궁금함.

실제 React 코드를 들여다보기 시작..

mountState에서 dispatch변수는 setter 함수이고 mountState 함수에서 마지막에 반환된다. dispatch는 dispatchAction 함수이며 currentlyRenderingFiber와 queue를 포함하고 있다. queue.dispatch는 dispatch function이랑 같은 참조를 하고 있다.

아오 삽질하면서도 뭔말인지 모르겠다 다음에 다시 하자.

삽질 Reference

전체 틀

React Codebase Overview

Fiber

Naver D2 React 파이버 아키텍처 분석
React Fiber Architecture

Hook 탄생 배경

[10분 테코톡] 룩소의 React Hooks

클로저 기반 설명

JSCont - Can Swyx recreate React Hooks and useState in under 30 min?

React Code 기반 분석

Under the hood of React’s hooks system
How does React associate Hook calls with components?
React Hooks - What's happening under the hood?
How Does setState Know What to Do?
How React Hooks Work - in depth + React Render Cycle Explained
How do react hooks determine the component that they are for?

마지막 수정일: