Untitled
import React, { useContext } from 'react'; import { Route, Navigate } from 'react-router-dom'; import { AuthContext } from '../context/AuthContext'; function Protected({ children }) { const { user } = useContext(AuthContext); if (!user) { return <Navigate to="/login" replace />; } return children; } export default Protected;