redux dispatch action from component code example
Example 1: dispatch two actions in redux
export const topLevelAction = () => dispatch => {
return Promise.all([dispatch(action1()), dispatch(action2()), dispatch(action3())])
}
Example 2: what is dispatch in redux
function dispatch(action) {
if (typeof action !== 'object' || obj === null) {
throw new Error('actions must be plain object.');
}
if (typeof action.type === 'undefined') {
throw new Error('Actions may not have an undefined "type" property.');
}
reducer(currentState, action);
}