import React, { useContext } from "react";
import { AuthContext } from "../Context/AuthProvider";
import { Navigate } from "react-router-dom";

const PrivateRoute = ({ children }) => {
  const { currentUserEmail } = useContext(AuthContext);
  return currentUserEmail === null ? <Navigate to="/" /> : children;
};

export default PrivateRoute;
