You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the new or updated feature that you are suggesting?
AFAIK, it is not possible at the moment for a component rendered in a route to determine whether that route matches exactly or not. The hook useParams only gives you access to the URL parameters, and useMatch forces you to provide full URL pattern, which breaks component isolation.
Why should this feature be included?
I'm facing a situation where a component rendered within a route needs to know whether it's a leaf (end) or not. In v5, I could use useRouteMatch and get access to isExact. Concept code would be as follows:
function Parent() {
// FIXME: how to know whether the current match is exact?
const isExact = true;
return (
<div className={isExact ? "has-children" : "">
<Outlet />
</div>
)
}
function Child() {
....
}
function App() {
return (
<Routes>
<Route path="/my/url/path" element={<Parent />}>
<Route path=":id" element={<Child />} />
</Route>
</Routes>
);
}
The text was updated successfully, but these errors were encountered:
Ok, that was just an example. The point is to know whether the closest route matches exactly or not. For instance, in the following useOutlet would always be null AFAIK:
What is the new or updated feature that you are suggesting?
AFAIK, it is not possible at the moment for a component rendered in a route to determine whether that route matches exactly or not. The hook
useParams
only gives you access to the URL parameters, anduseMatch
forces you to provide full URL pattern, which breaks component isolation.Why should this feature be included?
I'm facing a situation where a component rendered within a route needs to know whether it's a leaf (
end
) or not. In v5, I could useuseRouteMatch
and get access toisExact
. Concept code would be as follows:The text was updated successfully, but these errors were encountered: