Hook for detecting if a route is currently matched #376
ryanstaniforth
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
@ryanstaniforth Did you find a way to do this? I am having the same problem, trying to do some logic in the parent component, but not being able to get the current matched child route Edit: const matches = useMatches();
console.log(matches.map((m) => m.id)); I can get them with this, but IDK if there is a better way. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a use case for detecting if a child route is matched. I'm currently using the following:
I think something like this would be ideal, including typings for the available routes:
This functionality is similar to how
activeProps
on a link<Link>
works.P.S. Thank you for this amazing library @tannerlinsley, loving it so far.
Beta Was this translation helpful? Give feedback.
All reactions