Answer the question
In order to leave comments, you need to log in
Why is only the last dispatch executed?
Good day!
There was a problem with redax, before that I didn’t work with it at all.
I have a state in which the authorization state is stored and a state in which the user data is stored.
During the authorization process, when I try to get an updated state from the store, I only have the last dispatch, what could be the matter?
The authorization check method itself:
authStatus = (response) => {
if (response.message === "Success" || response.message === "Already login") {
this.props.loginState(true);
this.props.setUserData(response.result);
} else {
this.setState({
isOpenModalSignin: true
});
this.props.loginState(false);
}
};
connect(
state => ({
isLogin: state.isLogin,
userData: {
userName: state.userName,
email: state.email,
id: state.id
}
}),
dispatch => ({
loginState: (loginState) => {
dispatch({
type: "IS_AUTH",
payload: loginState
})
},
setUserData: (userData) => {
dispatch({
type: "USER_DATA",
payload: userData
}
);
}
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question