아래는 one-way data flow에 대한 설명이다.
state: the source of truth that drives our app;
view: a declarative description of the UI based on the current state
actions: the events that occur in the app based on user input, and trigger updates in the state
State describes the condition of the app at a specific point in time
The UI is rendered based on that state
When something happens (such as a user clicking a button), the state is updated based on what occurred
The UI re-renders based on the new state
위와 같은 one-way data flow는 여러 컴포넌트에서 같은 state를 사용할 시 문제가 발생할 수 있다.
이러한 문제 해결을 위해 state를 컴포넌트 밖에(global) centralize하여 사용한다.
This is the basic idea behind Redux:
a single centralized place to contain the global state in your application, and specific patterns to follow when updating that state to make the code predictable.
state
.dispatch({type: 'counter/increment'})
.state
and the current action
, and saves the return value as the new state
.정보 출처