Private Route--------
import { Navigate,useLocation} from "react-router-dom"
function Protecte({auth, children }) {
return auth ? children : <Navigate to="/login" />;
}
export default Protecte
-----------------------------------
App.js---
<Route path="/admin" element={
<Protecte auth={isLoggedIn}>
<Admin />
</Protecte>
}
/>