Closed themarvelme closed 7 years ago
Lets say that i have login action like following.
login
export function login(credentials) { return { types: ['LOGIN','LOGIN_SUCCESS','LOGIN_ERROR'], payload: { request: { url: '/api/login', method: 'POST',, data: credentials } } } }
When login is succeeded, i want to dispatch new action doAnother. How can i do that?
doAnother
Do i need to do that in reducer when action.type = LOGIN_SUCCESS? I guess its anti-pattern, and there must be more redux-like approach.
LOGIN_SUCCESS
Easy!
You can see in the docs that actions that are handled by this middleware return a Promise.
this.props.login(credentials) .then(() => { // router the user away this.context.router.push("/my/home/page") }) .catch((response) => { //handle login errors })
Lets say that i have
login
action like following.When login is succeeded, i want to dispatch new action
doAnother
. How can i do that?Do i need to do that in reducer when action.type =
LOGIN_SUCCESS
? I guess its anti-pattern, and there must be more redux-like approach.