[DevTools] Uncaught TypeError: contextMap[utilName] is not a function
Upgrading to
1.0.6 or beta-280 from beta-279 causes the following error when using inside of the RouterProvider
22 Replies
ratty-blushOP•2y ago
If I manually pass the router instance (with the same versions), I get the following error:
In either way, I am using the code as provided in the docs: https://tanstack.com/router/v1/docs/devtools#only-importing-and-using-devtools-in-development
Devtools | TanStack Router Docs
Link, take this sword... I mean Devtools!... to help you on your way!
Wave your hands in the air and shout hooray because TanStack Router comes with dedicated devtools! 🥳
ratty-blushOP•2y ago
Any help would be greatly appreciated as I am unable to upgrade past
beta-279, unless I remove the devtools.like-gold•2y ago
Could you confirm in your package.json that both
@tanstack/react-router and @tanstack/router-devtools are at 1.0.6
If not, try npm install @tanstack/react-router@latest @tanstack/router-devtools@latest.
If so, maybe try rm -rf your node_modules and give it a fresh npm install.
As someone on 1.0.6, I can confirm that the devtools package indeed works.ratty-blushOP•2y ago
Thank you @Sean Cassiere. I looked at the examples as well and I can see them working. I can confirm that the versions are the same. I get the same issue when doing a fresh install.
I had a little bit of an unconventional setup as I was trying to add a context. I think something broke that.
And in the main, I would use just
<AppRouterProvider />. I will have to find a different place to pass the context.
Thanks @Sean Cassiere!like-gold•2y ago
Provided your react-query and tRPC Providers are above the AppRouterProvider you really should be fine.
It's honestly weird that it's breaking at all.
ratty-blushOP•2y ago
Yes, react-query and tRPC providers are above the
AppRouterProvider. There is something going on with the const utils = trpc.useContext();. If I pass any other state to the context, it works fine. Somehow passing the utils is causing the error.
What doesn't make sense is passing the context causes issues with the devtoolsratty-blushOP•2y ago
Ok, I am getting closer. In
beta.279, the options in the DevTools is by default minimised. In beta.280 and above (including 1.0.6, it is expanded by default.
In 279, if I try to expand the options tab, I get the same error.

ratty-blushOP•2y ago
This is why I am seeing a difference between 279 vs 280 (and above). Seems like this didnt work before either.
ratty-blushOP•2y ago
@Sean Cassiere / @Tanner Linsley Does it make sense to file a bug for this on Github?
like-gold•2y ago
If you could replicate it on Stackblitz or Codesanbox, it certainly seems like something that deserves a GH Issue.
You could start here, and add the react-query and trpc stuff: https://stackblitz.com/github/TanStack/router/tree/main/examples/react/with-trpc
StackBlitz
Router With Trpc Example - StackBlitz
Run official live example code for Router With Trpc, created by Tanstack on StackBlitz
ratty-blushOP•2y ago
Thanks @Sean Cassiere . I was able to reproduce it in the stackblitz and created an issue here: https://github.com/TanStack/router/issues/909
GitHub
[DevTools] Obscure error "contextMap[utilName] is not a function" w...
Describe the bug When passing a context to the Router with the trpc.useUtils() hook causes an obscure error. function MyApp() { const utils = trpc.useUtils(); return <RouterProvider router={rout...
ratty-blushOP•2y ago
Out of curiosity, if I wanted to debug this, how would I make changes to the devtools package? Is it possible to do within stackblitz or what would be the ideal way?
like-gold•2y ago
I'm pretty sure you'd need to for the Router repo, add your example and then debug from there on.
ratty-blushOP•2y ago
Ok thanks!
like-gold•2y ago
I've added a couple comments to your github issue.
Gist of it is, that I think you were trying to pass React-only utils to your context that broke stuff.
Since the trpc-utils are only really useful for invalidating queries from the QueryClient, I used the recommended method from the trpc docs for achieving it.
ratty-blushOP•2y ago
Thanks Sean. I clarified your comment.
like-gold•2y ago
Got it working 🙌🏼
https://github.com/TanStack/router/issues/909#issuecomment-1874818888
GitHub
[DevTools] Obscure error "contextMap[utilName] is not a function" w...
Describe the bug When passing a context to the Router with the trpc.useUtils() hook causes an obscure error. function MyApp() { const utils = trpc.useUtils(); return <RouterProvider router={rout...
ratty-blushOP•2y ago
@Sean Cassiere Can you look at the ticket again?
like-gold•2y ago
Replied
ratty-blushOP•2y ago
Holy moly. Thanks @Manuel Schiller and @Tanner Linsley for fixing this! You guys are rockstars.
rival-black•2y ago
Mostly @Manuel Schiller