8 lines
230 B
TypeScript
8 lines
230 B
TypeScript
|
|
import {Navigate, Outlet} from "react-router-dom";
|
||
|
|
import {useAuth} from "@/context/AuthContext";
|
||
|
|
|
||
|
|
export default function ProtectedRoute() {
|
||
|
|
const {token} = useAuth();
|
||
|
|
return token ? <Outlet /> : <Navigate to="/" replace />;
|
||
|
|
}
|