Rotas no React-Router-Dom@6 e siga o caminho por uselocation () gancho

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