Skip to content

[Bug?]: v7 useMatches not working as expected in route module #12428

Discussion options

You must be logged in to vote

Based on the route you mentioned, that behavior is correct. Every file you mention is a leaf route (it has no routes nested inside). You need to add the handle to the layout routes too.

For example if you're on /app/account/password you will get the matches of these files:

  • app/root.tsx
  • app/routes/dashboard/layout.tsx
  • app/routes/dashboard/account/layout.tsx
  • routes/dashboard/account/password/route.tsx

But if you go navigate to /app/account you will get the matches of these other files:

  • app/root.tsx
  • app/routes/dashboard/layout.tsx
  • app/routes/dashboard/account/layout.tsx
  • app/routes/dashboard/account/route.tsx

See how the password route file is not matching anymore, so you won't get it, bu…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Pouet--
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by discoverlance-com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants