import React, { useContext } from "react"; import { Route, Redirect } from "react-router-dom"; import { AuthContext } from "../context/Auth/AuthContext"; import BackdropLoading from "../components/BackdropLoading"; const RouteWrapper = ({ component: Component, isPrivate = false, ...rest }) => { const { isAuth, loading } = useContext(AuthContext); if (loading) return ; if (!isAuth && isPrivate) { return ( ); } if (isAuth && !isPrivate) { return ; } return ; }; export default RouteWrapper;