Floating Routes (not in a Switch) #8907
Replies: 1 comment
-
import { useMatch } from "react-router-dom-v5-compat";
function Details() {
const match = useMatch("/details/about");
return (
<div>
<h1>Details</h1>
{match && <h2>About</h2>}
</div>
);
}; |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ryanflorence
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Reference: #8350
If you have a "floating route", or a route that's not in a
<Switch>
, you canuseMatch
instead.Eventually you'll want to move that up to the parent
<Routes>
, make it a child of the parent<Route>
, and use an<Outlet>
instead.Beta Was this translation helpful? Give feedback.
All reactions