Why don't chaining dispatch Redux Thunk? Only work first dispatch and second dispatch is not working.
Store:
const store = createStore(reducers, loadState(), applyMiddleware(thunk));
Action:
export function doSomething(name) {
return function (dispatch) {
dispatch({
type: 'USERNAME',
payload: name
})
dispatch({
type: 'OTHER_TYPE',
payload: 'text'
})
return true;
}
}
Edit It's worked:
return Promise.all([
dispatch({
type: 'USERNAME',
payload: name
}),
dispatch({
type: 'OTHER_TYPE',
payload: 'text'
})
])
From the docs: