import React from 'react'; import PropTypes from 'prop-types'; import { Route, Redirect } from 'react-router-dom'; const Authenticated = ({ loggingIn, authenticated, component, path, exact, ...rest }) => ( ( authenticated ? (React.createElement(component, { ...props, ...rest, loggingIn, authenticated })) : () )} /> ); Authenticated.propTypes = { loggingIn: PropTypes.bool.isRequired, authenticated: PropTypes.bool.isRequired, // elementType (not func): route components may be HOC-wrapped (translate(), // memo, forwardRef), which are objects, not plain functions. component: PropTypes.elementType.isRequired, }; export default Authenticated;