T
TanStack12mo ago
helpful-purple

addFileChildren not a function

This example uses .addChilren https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction This one uses .addFileChildren https://github.com/TanStack/router/blob/main/examples/react/basic-react-query-file-based/src/routeTree.gen.ts But neither works for me. I’m getting the error _routes_rootWEBPACK_IMPORTED_MODULE_0.Route._addFileChildren is not a function. Followed the template setup linked above, and everything looks correct.
TanStack | High Quality Open-Source Software for Web Developers
Headless, type-safe, powerful utilities for complex workflows like Data Management, Data Visualization, Charts, Tables, and UI Components.
From An unknown user
From An unknown user
GitHub
router/examples/react/basic-react-query-file-based/src/routeTree.ge...
🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering. - TanStack/router
11 Replies
realistic-cyan
realistic-cyan12mo ago
are you calling this manually?
helpful-purple
helpful-purpleOP12mo ago
No, it’s the generated routeTree file So I figured this out, in case anyone comes across. I wasn’t invoking the createRootRouteWithContext with two sets of parens. @Manuel Schiller maybe worth putting a note/warning in the docs to call attention to it. Pretty easy mistake to overlook for someone unfamiliar with the paradigm router uses.
realistic-cyan
realistic-cyan12mo ago
ah yeah you would have noticed this with typescript 🤪
helpful-purple
helpful-purpleOP12mo ago
🙂 tell that to my company
realistic-cyan
realistic-cyan12mo ago
looks like they need a consultant to tell them 🤓
rising-crimson
rising-crimson7mo ago
if anyone else runs into this while upgrading tanstack (even though typescript tells you nothing), _addFileChildren was added in @tanstack/react-router@1.56.1.
realistic-cyan
realistic-cyan7mo ago
just use typescript ?
rising-crimson
rising-crimson7mo ago
I guess it was not clear, I am
realistic-cyan
realistic-cyan7mo ago
so what problem did you run into here?
rising-crimson
rising-crimson7mo ago
was upgrading router-plugin, devtools and router itself from 1.45.7. If you upgrade to 1.47.x all 3 packages, it ends up generating routes with that function used, tsc happily compiles (for some reason), but you get a runtime error
realistic-cyan
realistic-cyan7mo ago
might have been a version where peer deps were not yet correctly specified nowadays you should always get a matching plugin and router version when deps are resolved

Did you find this page helpful?