Untitled
unknown
plain_text
2 years ago
368 B
45
Indexable
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;Editor is loading...