Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
303 B
4
Indexable
Never
import React from 'react';
import { Navigate } from 'react-router-dom';
import { useAuth } from '../context/AuthContext';

const PrivateRoute = ({ children }) => {
  const { isAuthenticated } = useAuth();

  return isAuthenticated ? children : <Navigate to="/login" />;
};

export default PrivateRoute;
Leave a Comment