TanStackT
TanStack2y ago
3 replies
sad-indigo

How should I be expected to parse params ?

Hello there, I'm currently migrating one of our frontends to tsr from react-router.
I would like to be able to parse the route's path params through a zod parser.
z.object({
  systemId: systemId.optional(),
  activityId: activityId.optional(),
})

but when I try to:
const galaxyRoute = createRoute({
  getParentRoute: () => rootRoute,
  path: "/galaxy/$systemId/$activityId",

  parseParams: (params) => 
      z.object({
        systemId: systemId.optional(),
        activityId: activityId.optional(),
      })
      .parse(params),
  
}).lazy(() => import("./pages/galaxy").then((d) => d.Route))

I get an error:
parseParams must return an object


What am I doing wrong here ?
I didn't find too much documentation on the parseParams, no in code description too.
If I'm able to parseParams should I not be allowed to transform it to something else ?

PS: It seems to go away if I return some kind of record ?
Was this page helpful?