📅  最后修改于: 2022-03-11 15:03:23.908000             🧑  作者: Mango
const PrivateRoute = ({component: Component, ...rest}) => {
const {isAuthenticated} = rest;
return (
(
isAuthenticated ? (
) : (
)
)}
/>
);
};
PrivateRoute.propTypes = {
isAuthenticated: PropTypes.bool.isRequired,
};
function mapStateToProps(state) {
return {
isAuthenticated: state.user.isAuthenticated,
};
}
export default connect(mapStateToProps)(PrivateRoute);