Маршруты в React-Router-Dom@6 и пройдите путь по useLocation () крючку

function App() {
  const location = useLocation();
  const [activePlanet, setActivePlanet] = useState('/');

  return (
    <Routes location={location}>
      <Route
        path="/"
        element={
          <DefaultLayout pathName={location.pathname} setActivePlanet={setActivePlanet} activePlanet={activePlanet} />
        }>
        <Route index element={<Home activePlanet={activePlanet} />} />
        {routes.map((route, idx) => (
          <Route key={`route-${idx}`} path={route.path} element={route.element} />
        ))}
      </Route>
    </Routes>
  );
}
danghai