useReducer와 Context는 상태 계산과 공급 책임을 나눠 맡는다

reducer는 action으로 다음 state를 계산하고 Provider는 state와 dispatch를 하위 컴포넌트에 공급한다.

1

핵심 1

useReducer와 Context는 상태 계산과 공급 책임을 나눠 맡는다

2

핵심 2

useReducer와 Context는 상태 계산과 공급 책임을 나눠 맡는다

3

핵심 3

reducer는 action으로 다음 state를 계산하고 Provider는 state와 dispatch를 하위 컴포넌트에 공급한다.

4

핵심 4

Reducer state + action -> next state Provider state, dispatch 공급 Consumer state 읽기…

핵심useReducer Context 조합은 계산 규칙과 공급 범위를 분리할 때 깔끔해진다.