javascript - redux dispatch action and reducer with new state -
i have actions like:
export function login(){ my_login(function(response){ if(response.status == "ok"){ loginsuccess(response) } }) } export function loginsuccess(response){ return dispatch => { dispatch({ response, type: types.login }); console.log("dispatched"); console.log(getstate()); ---> want updated state router.transitionto("/some_url");----> after want route somewhere }; }
when login
action called again calls my_login
, dispatching loginsuccess
action.
i have reducer like:
const initialstate = [ { fname: null, lname: false, } ] export default function login(state = initialstate, action) { switch (action.type) { case login: console.log("actions dude") console.log(action) return [{ fname: action.fname, lname: actin.lname, }] default: return state } }
here state not changing , not getting getstate()
value in action above.
i dont think reducer called , state updated.
can sugges me whats wrong in here ?
i think missing dispatch(loginsuccess(response))
Comments
Post a Comment