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
Hi there. We are trying to upgrade our product to v6, and are running into an issue with default routes. We have a component TradeScreen that displays trades for a certain date, and use the path /trades/:yyyy/:mm/ to get there. We also want the path /trades/ to route to the current year and month.
The naive approach to this was something like this:
This sort of works, but because <Navigate> uses an effect, it actually renders the page, then does the redirect.
I understand why this needs to be an effect, but I wonder if it would make sense to have a callback that we could use, like translatePath() where we could say "please route /trades as if it were /trades/2020/07". Or maybe there is just a routing table that we pass in with the original <Router>. That keeps the underlying component independent of this routing logic but doesn't force a client-side redirect.
Open to other approaches to this, but feels like we need something here. (Also, before you say "why don't you just make the default year/month in your component if nothing is passed... sure... but how about a simple case where I want to route / to /trades when the user logs in?)
The text was updated successfully, but these errors were encountered:
Hi there. We are trying to upgrade our product to v6, and are running into an issue with default routes. We have a component
TradeScreen
that displays trades for a certain date, and use the path/trades/:yyyy/:mm/
to get there. We also want the path/trades/
to route to the current year and month.The naive approach to this was something like this:
This sort of works, but because
<Navigate>
uses an effect, it actually renders the page, then does the redirect.I understand why this needs to be an effect, but I wonder if it would make sense to have a callback that we could use, like
translatePath()
where we could say "please route/trades
as if it were/trades/2020/07
". Or maybe there is just a routing table that we pass in with the original<Router>
. That keeps the underlying component independent of this routing logic but doesn't force a client-side redirect.Open to other approaches to this, but feels like we need something here. (Also, before you say "why don't you just make the default year/month in your component if nothing is passed... sure... but how about a simple case where I want to route
/
to/trades
when the user logs in?)The text was updated successfully, but these errors were encountered: