You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you build the example and load the url /abc/mno you will see (as expected):
willTransitionTo called in abc while transitioning to /abc/mno
willTransitionTo called in mno while transitioning to /abc/mno
willTransitionTo called in pqr while transitioning to /abc/mno/pqr
When you comment out line 36 and uncomment 37 in app.js and rebuild you see this output: (If you don't see this behavior it's because you are not landing on /abc/mno you are transitioning to it)
willTransitionTo called in abc while transitioning to /abc/mno
willTransitionTo called in abc while transitioning to /abc/mno/pqr <-- This shouldn't have happened
willTransitionTo called in mno while transitioning to /abc/mno/pqr
willTransitionTo called in pqr while transitioning to /abc/mno/pqr
Note an addition call to willTransitionTo after the transition.redirect in the /abc/mno handler.
The text was updated successfully, but these errors were encountered:
It doesn't surprise me that Router.replaceWith inside a willTransitionTo is giving you different behavior than transition.redirect. In that case you're essentially circumventing the transition object entirely so it has no idea it has been aborted. You should definitely avoid doing this because you're essentially kicking off a second transition before the first one has completed. In fact, we should probably throw if someone tries to do this. So the first log output you see (the 3 lines) is actually undefined behavior.
The second set of log statements is actually what you should expect. When willTransitionTo is called in abc, it hits the call to transition.redirect and immediately aborts the transition, redirecting to the new route.
I am seeing two different behaviors between three different ways to do the same thing.
Redirect
componentRouter.replaceWith()
in awillTransitionTo
calltransition.redirect
in awillTransitionTo
callwillTransitionTo
function on every handler in the chain <-- This is the odd duck!I primarily see this issue when loading the page to a url that will do
transition.redirect
within awillTransitionTo
call. See the console log output on this example: https://github.com/mtscout6/react-router/tree/router-redirect-vs-relaceWith-vs-tansition-redirect/examples/redirectIf you build the example and load the url
/abc/mno
you will see (as expected):When you comment out line 36 and uncomment 37 in app.js and rebuild you see this output: (If you don't see this behavior it's because you are not landing on
/abc/mno
you are transitioning to it)Note an addition call to
willTransitionTo
after thetransition.redirect
in the/abc/mno
handler.The text was updated successfully, but these errors were encountered: