We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useMatch able to take an array of different paths to match like useRouteMatch
Allowing for possible match conditions to meet instead of just one
example:
const routeMatch = useRouteMatch(['/inbox/:id', '/drafts', '/trash']); const currentTab = routeMatch?.path; return ( <Tabs value={currentTab}> <Tab label="Inbox" value="/inbox/:id" to="/inbox/1" component={Link} /> <Tab label="Drafts" value="/drafts" to="/drafts" component={Link} /> <Tab label="Trash" value="/trash" to="/trash" component={Link} /> </Tabs> ); }```
The text was updated successfully, but these errors were encountered:
Unfortunately, this would make #8030 significantly more difficult to implement.
Since useMatch just wraps matchPath with a call to useLocation, I would just do this yourself in a map or find loop:
useMatch
matchPath
useLocation
const paths = ['/inbox/:id', '/drafts', '/trash'] const location = useLocation() const match = paths.find(path => matchPath(path, location.pathname))
I don't think this is something we're going to support in the library itself.
Sorry, something went wrong.
No branches or pull requests
What is the new or updated feature that you are suggesting?
useMatch able to take an array of different paths to match like useRouteMatch
Why should this feature be included?
Allowing for possible match conditions to meet instead of just one
example:
The text was updated successfully, but these errors were encountered: