blob: 341625e431e1c083eab05485b055f2356d9d7303 (
plain) (
tree)
|
|
import React from 'react';
import { Navigate, Outlet } from 'react-router-dom';
import { useAuth } from '../contexts/AuthContext';
const PrivateRoute = () => {
const { currentUser } = useAuth();
if (currentUser === undefined) {
return <div>Loading...</div>; // Or a spinner/loading component
}
return currentUser ? <Outlet /> : <Navigate to="/login" />;
};
export default PrivateRoute;
|