PopcornPing / frontend /src /components /ProtectedRoute.jsx
Yash Goyal
Correction
2070fe3
raw
history blame contribute delete
486 Bytes
import React from 'react';
import { Navigate } from 'react-router-dom';
import { useAuth } from '../context/AuthContext';
const ProtectedRoute = ({ children }) => {
const { user, loading } = useAuth();
if (loading) {
return (
<div className="min-h-screen flex items-center justify-center bg-gray-900">
<div className="text-white text-xl">Loading...</div>
</div>
);
}
return user ? children : <Navigate to="/" />;
};
export default ProtectedRoute;