useReducer와 Context는 상태 계산과 공급 책임을 나눠 맡는다
reducer는 action으로 다음 state를 계산하고 Provider는 state와 dispatch를 하위 컴포넌트에 공급한다.
Reducer
state + action -> next state
Provider
state, dispatch 공급
Consumer
state 읽기
Button/Form
dispatch 호출
역할
맡는 일
주의
reducer
순수 상태 계산
비동기 작업 넣기
action
변경 의도 표현
모호한 type
Provider
공급 범위 설정
value 객체 불안정
consumer
읽기/요청
state 직접 수정