javascript - Redux transition to after action execution -


i have action

export function loginsuccess(response){     return (dispatch, getstate) => {     dispatch({ response, type: types.login });     router.transitionto("/profile")    }; } 

here after successful execution of action redirect /profile.

here getting router not defined.

you have pass router redux thunk action creator (you pice of code not action wrote action creator). example looks like:

export function loginsuccess(router, response){   return (dispatch, getstate) => {     dispatch({ response, type: types.login });     router.transitionto("/profile")    }; } 

do have access router in place invoke action creator ? available there? if yes have there (i don't know response):

this.props.dispatch(loginsuccess(response)); 

and have change to:

this.props.dispatch(loginsuccess(this.context.router, response)); 

i assume have access router context.

because don't show how invoke action i'm guessing. hope instruction you.

and 1 more thing. new react-router api don't have transitionto method in router! don't know if use new or old api. if error like:

calling transitionto fails with: 'location.search.substring not function'

then change :

router.transitionto("/profile") 

to:

router.push("/profile") 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -