T
TanStack3y ago
ambitious-aqua

Devtools - Uncaught Error: Invariant failed

Does anyone have an idea why I'm getting that error when using the router dev tools. I followed the documentation BTW and I'm using react 18.2.0
No description
11 Replies
correct-apricot
correct-apricot3y ago
I've looked into the source code and it seems like you aren't mounting the Devtools under the RouterProvider. You need to either mount in inside, so it can access router instance from context. Or pass it manually as prop
correct-apricot
correct-apricot3y ago
GitHub
router/packages/router-devtools/src/devtools.tsx at 8814f47ba42a2db...
🤖 Type-safe router w/ built-in caching & URL state management for React, Preact, and friends - TanStack/router
ambitious-aqua
ambitious-aquaOP3y ago
I saw that previously I passed my router to it but still the same error. I don't think I need to pass my router to it, It's on the same level as my outlet
correct-apricot
correct-apricot3y ago
Hmm, that's strange. Is your Devtools and router packages version in sync?
ambitious-aqua
ambitious-aquaOP3y ago
export const rootRoute = new RootRoute({
component: function () {
return (
<>
<Outlet />
<TanStackRouterDevtools />
</>
);
},
});
export const rootRoute = new RootRoute({
component: function () {
return (
<>
<Outlet />
<TanStackRouterDevtools />
</>
);
},
});
Yes I made sure they are in sync
correct-apricot
correct-apricot3y ago
Hmm then I don't have more ideas, sorry
ambitious-aqua
ambitious-aquaOP3y ago
No description
ambitious-aqua
ambitious-aquaOP3y ago
No description
stormy-gold
stormy-gold3y ago
Try with the latest now
absent-sapphire
absent-sapphire3y ago
I am facing the same issue and had pass router instance manually: <TanStackRouterDevtools router={router} />
foreign-sapphire
foreign-sapphire3y ago
i working around by using this to get the router import { routerContext } from "@tanstack/react-router"; const router = useContext(routerContext);

Did you find this page helpful?