UNSAFE_ rename of our 4 componentWillReceiveProps (FireStats, Fires, FromNow, SelectionMap) and Authenticated/Public component propType func -> elementType. Rest of the console noise is legacy react-* dev-mode warnings, absent in prod.
25 lines
774 B
JavaScript
25 lines
774 B
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { Route, Redirect } from 'react-router-dom';
|
|
|
|
const Authenticated = ({ loggingIn, authenticated, component, path, exact, ...rest }) => (
|
|
<Route
|
|
path={path}
|
|
exact={exact}
|
|
render={props => (
|
|
authenticated ?
|
|
(React.createElement(component, { ...props, ...rest, loggingIn, authenticated })) :
|
|
(<Redirect to="/login" />)
|
|
)}
|
|
/>
|
|
);
|
|
|
|
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;
|