Matches after route Param
Hello! I have a simple file based route layout with a parameter for a venue slug (TSR 1.48.1):
routes/
venues/
$venueId/
index.tsx
reviews.tsx
when I access /venues/venue-slug/reviews
The devtools and output of useMatches has the following
__root__
/
/venues
/venues/venue-slug/reviews
Would I be incorrect to assume that there should be this structure in the Matches list?:
__root__
/
/venues
/venues/venue-slug (or venues/$venueId)
/venues/venue-slug/reviews
I'm trying to use the meta set for each part of the route (in RouteOptions
) to build breadcrumbs, but anything after the $venueId
param seems to be squashed in to a single match. Is there a way of achieving this using file based routing? Thank you for looking!6 Replies
ambitious-aquaOP•14mo ago
This looks like a similar issue/query to the one in @Sagar s post below
deep-jade•14mo ago
It only matches the routes if their files exist.
Because you can create this route
/venues/$venueId/reviews
without any of the parent route files.
So, you'd need to define the individual venue.tsx
and venue.$venueId
files as well.
Without it, visiting /venues
throw a notFound
error since you haven't defined a route for that path.ambitious-aquaOP•14mo ago
Thanks for the quick reply Sean, I will try that
ambitious-aquaOP•14mo ago
ambitious-aquaOP•14mo ago
And of course, it worked
deep-jade•14mo ago
Yea it sounded familiar to the issues people run into when trying to implement breadcrumbs.
Happy to help