Using file based router to manage directories routes and redirect to child route.

If using file based router, like:
layout/
  index.tsx
  foo.tsx
  bar.tsx

In index.tsx:
export const Route = createFileRoute('/_admin/layout/')({
  loader: () => {
    throw redirect({ to: '/layout/foo.tsx' });
  },
});

It works but routeTree was flatten;
Then I try to change index.tsx to route.tsx, route.tsx can make nested routeTree, but seems using redirect in route.tsx loader will caused error
Warning: Tried to render a redirected route match! This is a weird circumstance, please file an issue!


So,How can I make this works:
- file based route;
- /layout will redirect to /layout/foo;
- using directories to organize all routes/pages in layout/;
Was this page helpful?