todos-contra-el-fuego-web/imports/ui/components/Authenticated/Authenticated.js
vjrj a997aa7cae cleanup: silence our own React dev-console warnings
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.
2026-07-18 05:47:44 +02:00

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;