Parent route match in useMatchRoute #977
-
Let's say I have a route like I would also like to check if parent What's the best way to check if parent route is matching? Is it supported directly in Tanstack Router v1 or do I need to do some custom substring checks? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
how would the parent route not match if the child route matches? I probably don't understand your problem, can you please create a minimal example on codesandbox? |
Beta Was this translation helpful? Give feedback.
-
@schiller-manuel Just building on this discussion as it's fairly related... I want to style a parent element based on one of its child Links being active, but the child Links do not all have the same path prefix. Example folder structure below (_resources.tsx has some beforeLoad auth checks in).
This will render in a nav along the lines of:
I was hoping to be able to do something like: |
Beta Was this translation helpful? Give feedback.
You can use
matchRoute({to: '/posts', fuzzy: true})
.There was a bug with fuzzy matching but this is fixed in v1.4.5 https://github.com/TanStack/router/releases/tag/v1.4.5