T
TanStack7mo ago
provincial-silver

matchRoute matches pending location

Hey, I have a small helper utility for matchRoute and I run into some issues with it returning in a in-between state. For the setup: - I have a redirect in my beforeLoad that is async that always redirects towards $organizationId/$projectId if you're not on any subpath of it - My link navigates to $organizationId - My component consumes matchRoute("$organizationId/$projectId") I kind of expected the navigation event to keep the old router state for the component tree until the loaders (including beforeLoad) are resolved and then swap it over but it seems that there is a in-between state where the click on the Link leads to the route not being matched for a split-second. There is a screenshot attached of the router states and what is being matched attached. pending is undefined but even when I set it to false, it seems to either take the route matching from state.location or state.pendingMatches which seems off because the state.matches array seems more correct I'm not sure if this is a misunderstanding on my part, but it feels "off" because the pattern of components being useable on sections of routes seems sensible and it not being compatible with redirects in async beforeLoad is kind of a bummer
No description
2 Replies
exotic-emerald
exotic-emerald7mo ago
the location changes as soon as navigation starts can you show how you use that in a complete minimal example by forking one of the existing examples on stackblitz please?
provincial-silver
provincial-silverOP7mo ago
Sure, but I sadly won't get to it until Monday

Did you find this page helpful?