Spaces:
Runtime error
Runtime error
| import { Navigate, Outlet } from 'react-router-dom'; | |
| import { useAuth } from '../context/AuthContext'; | |
| const ProtectedRoute = () => { | |
| const { isAuthenticated, isLoading } = useAuth(); | |
| if (isLoading) { | |
| return <div>Loading...</div>; | |
| } | |
| return isAuthenticated ? <Outlet /> : <Navigate to="/login" replace />; | |
| }; | |
| export default ProtectedRoute; | |