- action -> reducer -> store
基础
action
描述对state
要发生什么?(为state
的改变提供数据,数据的唯一来源)
1 | { |
Action Creater
动作创建函数1
2
3
4
5
6function addTodo(text) {
return {
type: "ADD_TODO",
text,
}
}
reducer 规约器
将actions描述的发生事情更新为state
(prevState, actions) => newState
1 | function todoApp(state, action){ |
combineReducer()
store
维持应用状态,提供dispatch(action)
1 | let store = createStore(todoApp); |
1 | /../captainweekly/Weekly/resources/20200918/redux-in-chinese.pdf |
- 目标、方案、执行者