The state of your whole application is stored in an object tree within a single store.
Maintain our application state in a single object which would be managed by the Redux store.
The only way to change the state is to emit an action, an object describing what happened.
To update the state of your app, you need to let Redux know about that with action.
Not allowed to directly update the state object.
To specify how the state tree is transformed by actions, you write pure reducers.
Reducer function - (previousState, action) => newState
JavaScript App이 있다. 이 App의 State는 Redux Store
라는 별도의 공간에서 관리한다.
App은 Redux Store
를 구독하고 있다. 그러나 App에서 Redux Store
의 state를 직접 업데이트 할 수는 없다.
App이 state를 업데이트 하려면 action
을 dispatch
(emit) 해야 한다.
action
이 dispatch
되면 Reducer
가 그 action
을 처리하여 현재 state를 업데이트 한다.
state가 업데이트되는 즉시 App에 전달된다(subscribe하고 있으므로).
이것이 Redux의 기본 동작 원리이다.