import React from 'react'; import { Route, Redirect } from 'react-router-dom'; const PrivateRoute = ({ component: Component, ...rest }) => { const isAuthenticated = !!localStorage.getItem('token'); return ( isAuthenticated ? : } /> ); }; export default PrivateRoute;