TanStackT
TanStack14mo ago
21 replies
brilliant-lime

Invariant failed useMatch

Hello,
I don't exactly why but sometime, when I click on a <Link><Link>, I have Invariant failed which appear.


Error: Invariant failed
    at invariant (tiny-invariant.js:8:15)
    at Object.select (useMatch.js:14:7)
    at useRouterState.js:21:19
    at a3 (with-selector.production.min.js:11:204)
    at with-selector.production.min.js:11:420
    at Object.useSyncExternalStore (react-dom.production.min.js:178:368)
    at react_production_min.useSyncExternalStore (react.production.min.js:26:309)
    at withSelector_production_min.useSyncExternalStoreWithSelector (with-selector.production.min.js:11:489)
    at useStore$1 (index.js:4:49)
    at useRouterState (useRouterState.js:11:10)


When I add a breakpoint, The error is 'could not find a nearest match'

My current setup for these routes are:

When I click on /routeA/$id, I fetch the entity and sub entity in the loader and then I throw a redirect to /route/$id/sub/$subId
Was this page helpful?