Replies: 2 comments 1 reply
-
it's actually a problem even to get the handle for the current route... right now i have to loop through the result of useMatches, find the one matching the current location, then extract the handle from there :(
|
Beta Was this translation helpful? Give feedback.
0 replies
-
matchRoutes(routes, pathname) ? |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
What is the new or updated feature that you are suggesting?
useMatches only works with a data router like createBrowserRouter, since they know the full route tree up front and can provide all of the current matches. Additionally, useMatches will not match down into any descendant route trees since the router isn't aware of the descendant routes.
So, How can I get handles for any descendant route
So, I expect useMatch's return value to contain both the current handle and the parent handle
Why should this feature be included?
This lets me get rid of the useMatches to deal with the breadcrumb problem, because instead of getting the descendant route, I'm getting the current and parent route data, which I know for sure
const { handles } = useMatch()
If you do not want to change the useMatch api, you can create a new hook useHandles
const handles = useHandles()
The least you can do is give me another way to get the handle on the descendant route
Beta Was this translation helpful? Give feedback.
All reactions