import React from 'react'; import PropTypes from 'prop-types'; import { Route, Redirect, } from 'react-router-dom'; const ProtectedRoute = ({ component: Component, ...rest }) => { const { location: { state: { isAuthenticated = false } = {} } = {} } = rest; return ( ( isAuthenticated ? () : () )} /> ); }; ProtectedRoute.propTypes = { component: PropTypes.func }; export default ProtectedRoute;