File based routing /post/new route matching
Hi, I'm making a simple CRUD app using file based routing and I have the following files
posts.tsx
posts.new.tsx
but the issue is that my
NewPostComponent
shared the layout of the PostComponent
(doesn't have an <Outlet /> either) but I actually want /post/new
's root component to be my __root
component. would this be possible in file based routing?4 Replies
other-emeraldOP•14mo ago
for the time being I've opted out of file based routing. So far code-basde routing has been a better experience in my opinion
deep-jade•14mo ago
You may have just needed an index route to have gotten this working.
Code-based routing is always available 👍🏼
It does have worse DX and typescript performance though.
stormy-gold•13mo ago
To your orignial Question @Miguel , I think Non-Nested Routes may solve your problem? https://tanstack.com/router/latest/docs/framework/react/guide/routing-concepts#non-nested-routes
Basically rename
posts.new.tsx
to posts_.new.tsx
. That way, if I understood this correctly, NewPostComponent
will not share the layout of PostComponent
.other-emeraldOP•13mo ago
@lanice thanks, that works too