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
I recently needed to add some redirect to some of my routes and was surprised that there wasn't an existing solution. Here's what I ended up with, works great for me and is pretty straightforward.
This adds a redirect function prop to routesMap, which will be used in onBeforeChange to redirect if redirect returns a value. Note that in my case I needed to use initialDispatch because I need to fetch some user data before I can execute the redirect logic.
This is working pretty well for my current use case but it could probably be more robust. redirect could also accept the payload or action as a second arg. Maybe it would also make sense for redirect to return an action instead of the action type string for better control over redirecting the payload or metadata.
If this approach makes sense it would be nice to have it integrated into connectRoutes. I noticed this was an active help topic for wanted PRs, I can open a PR if it will be helpful.
The text was updated successfully, but these errors were encountered:
I recently needed to add some redirect to some of my routes and was surprised that there wasn't an existing solution. Here's what I ended up with, works great for me and is pretty straightforward.
This adds a
redirect
function prop toroutesMap
, which will be used inonBeforeChange
to redirect ifredirect
returns a value. Note that in my case I needed to useinitialDispatch
because I need to fetch some user data before I can execute the redirect logic.This is working pretty well for my current use case but it could probably be more robust.
redirect
could also accept the payload or action as a second arg. Maybe it would also make sense forredirect
to return an action instead of the action type string for better control over redirecting the payload or metadata.If this approach makes sense it would be nice to have it integrated into
connectRoutes
. I noticed this was an active help topic for wanted PRs, I can open a PR if it will be helpful.The text was updated successfully, but these errors were encountered: