Is there a way to get the current (active) sub-route without using state
?
For example, there is:
<Route path="home/*" element={<Home />}>
<Route index element={<Main />} />
<Route path="about" element={<About />} />
</Route>
I would like to have a hook that I would use inside Home
like this:
const Home = () =>
useMyHook().activeSubPath === "about" ? (
<>
<h1>We are at about page</h1>
<Outlet />
</>
) : (
<Outlet />
);