Part One: Core Concepts
store
action
reducer
store
reducer
Redux
state
action
UI
DOM Event
Network
……
Redux's primary goal is to make state mutations predictable
by imposing restrictions on how and when updates can happen.
The state of your whole application is stored in an object tree within a single store.
Tips
The only way to change the state is to emit an action, an object describing what happened.
Tips
To specify how the state tree is transformed by actions, you write pure reducers.
Tips
redux/createStore.js
createStore
const enhancers = [enhancer1, enhancer2, enhancer3];
const enhancer = compose(...enhancers);
Enhanced createStore
enhancer3
enhancer2
enhancer1
reducer,preloadedState
redux/createStore.js
dispatch
const middlewares = [middleware1, middleware2, middleware3];
applyMiddleware(...middlewares);
Enhanced store.dispatch
middleware3
middleware2
middleware1
action
store
reducer
Redux
state
action
UI
DOM Event
Network
……
React-Redux
React
store
Provider
Root
Component
Sub
Component
Sub
Component
Wrapper
Component
store (by context)
props by
mapStateToProps &
mapDispatchToProps