T
TanStack4y ago
environmental-rose

Any way to do a partial or fuzzzy match

I have these paths "/" | "/app" | "/app/books" | "/app/books/create" My sidebar has 2 links. the "Home" one which points to /app and a books one which points to /app/books I want to match "/app/books/create" to the /app/books link but not the /app link currently I tried const match = router.matchRoute({ to: url }); which only matches exact urls and const match = router.matchRoute(url); which seems to match everything I was able to do this with react location using
const matchRoute = useMatchRoute();
const match = matchRoute({
to: `${url}`,
fuzzy: true,
});
const matchRoute = useMatchRoute();
const match = matchRoute({
to: `${url}`,
fuzzy: true,
});
Is there a recommended way to do this yet?
4 Replies
optimistic-gold
optimistic-gold4y ago
fuzzy should work just the same in TanStack Router. If you have a codesandbox or stackblitz that shows otherwise, paste the link into a new github issue.
environmental-rose
environmental-roseOP4y ago
Tnx so much. submitted an issue https://github.com/TanStack/router/issues/374
GitHub
Fuzzy option not available on matchRoute · Issue #374 · TanStack/ro...
Describe the bug The fuzzy option does not seem to be available in tanstack router. Something like this will throw a type error and does not work during runtime as well const match = router.matchRo...
environmental-rose
environmental-roseOP4y ago
This seems to work in runtime but showing type errors
No description
optimistic-gold
optimistic-gold3y ago
This should be fixed now.

Did you find this page helpful?