Rute di react-router-dom@6 dan mengambil jalan dengan hook 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