T
TanStack2y ago
solid-orange

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
layout/
index.tsx
foo.tsx
bar.tsx
In index.tsx:
export const Route = createFileRoute('/_admin/layout/')({
loader: () => {
throw redirect({ to: '/layout/foo.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!
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/;
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?