I Have the redux connected in my code
loginAction(){
console.log("dashboard login action");
this.props.login("username","password")
console.log("mapstate to props dashboard "+JSON.stringify(
this.props.loginStatus));
}
const mapStateToProps = (state) => {
return {
loginStatus:state.loginStatus
};
}
when I try to access this.props.loginStatus after calling the this.props.login("username","password") method,this becomes undefined. When i observed it is because it takes time to update the store. How to figure out when the store update is done by a callback or something,when the store updated i can get the this.props.loginStatus
export default function LoginReducer(state = initialstate, action) {
console.log("loginreducer calling =" + action.type + " " + JSON.stringify(
action.payload));
switch (action.type) {
case "USER_LOGIN":
console.log("case USER_LOGIN");
//axiox get auth url
return Object.assign({}, state, action.payload)
default:
return state
}
}
attached is my reducer