12 lines
269 B
TypeScript
12 lines
269 B
TypeScript
import { Navigate, Outlet } from 'react-router-dom';
|
|
import { useAuth } from './AuthContext';
|
|
|
|
export default function PublicRoute() {
|
|
const { isAuthenticated } = useAuth();
|
|
|
|
if (isAuthenticated) {
|
|
return <Navigate to="/" replace />;
|
|
}
|
|
|
|
return <Outlet />;
|
|
} |