Nested Dynamic routes
Hi!
It's probably my fault, but I can't find a solution! So my problem is that I have following structure:
And following code to each file.
index.tsx
$postId.tsx
$postId.edit.tsx
but when I reach to
http://localhost:3001/posts/24/edit
the output is Hello posts.$24.tsx
but it should be: Hello posts.${postId}.edit.tsx
it's like *.edit.tsx doesn't work for some reason... But when I did same things with FLAT ROUTES it worked fine. Why is that?5 Replies
quickest-silver•7mo ago
Could you try renaming your
$postId.tsx
file to $postId.index.tsx
?metropolitan-bronzeOP•7mo ago
when i renamed it I have following typescript error:
in here:
export const Route = createFileRoute('/posts/$postId/')({
component: RouteComponent,
});
and it's not working ;/
wise-white•7mo ago
Hmm. Can you try $postId_.edit.tsx? It would opt you out of the parent since you’re not wanting to share the “layout” of $postId. Otherwise you’d need an Outlet on the $postId route
metropolitan-bronzeOP•7mo ago
Works fine! THanks @Eric Chernuka 🙂
wise-white•7mo ago
Amazing! Glad you’re good to go.