action设计原则文档 https://redux.js.org/tutorials/fundamentals/part-3-state-actions-reducers#designing-actions
对象格式
- type 消息名称
- payload 传入的参数
{type: 'todos/todoAdded', payload: todoText}
{type: 'todos/todoToggled', payload: todoId}
{type: 'todos/colorSelected, payload: {todoId, color}}
{type: 'todos/todoDeleted', payload: todoId}
{type: 'todos/allCompleted'}
{type: 'todos/completedCleared'}
{type: 'filters/statusFilterChanged', payload: filterValue}
{type: 'filters/colorFilterChanged', payload: {color, changeType}}
dispatch
组件中 dispatch派发
onClick = (e) => {
const action = {
type: 'change_lang',
payload: e.key
}
store.dispatch(action)
}
redux-saga
Redux-Saga 以 Redux 中间件 的形式而存在,主要是管理 Redux 应用程序中的副作用(Side Effects)
https://www.yuque.com/fe9/select/miya5f
redux-thunk的缺点
https://blog.csdn.net/liwusen/article/details/80980987