import React from 'react' ; import { Route , Redirect , RouteProps , RouteComponentProps } from 'react-router-dom' ; const PrivateRoute = ( { component , ... rest } ) : JSX . Element => { if ( ! component ) { throw Error ( 'component is undefined' ) ; } const Component = component ; return ( < Route { ... rest } render = { ( props ) => localStorage . getItem ( 'jwt' ) ? < Component { ... props } / > : < Redirect to = "/login" / > } />); } ; export default PrivateRoute ;