TanStackT
TanStack15mo ago
4 replies
conventional-black

How to use params.parse?

Before deprecation of parseParams, I used to do

export const Route = createFileRoute('/post/$id/_layout')({
  component: Outlet,
  parseParams: ({ id }) => {
    if (/^\d+$/.test(id)) {
      return { id: Number(id) };
    }
    throw new Error('Invalid ID: must be an integer');
  },
});


Couldn't figure out how to implement the same behaviour with parse.params method.
Was this page helpful?