我有这段代码:
import React, { Component, PropTyps } from 'react';
import { connect } from 'react-redux';
export default function (ComposedComponent) {
class RequireAuth extends Component {
static propTypes = {
router: React.PropTypes.object
}
componentWillMount() {
this.checkAuth();
}
componentWillUpdate(nextProps) {
this.checkAuth();
}
checkAuth() {
if (!this.props.authenticated) {
this.context.router.push('login');
}
}
render() {
return (
<div>
{this.props.authenticated === true ? <ComposedComponent {...this.props} /> : null}
</div>
);
}
}
const mapStateToProps = (state) => {
return {
authenticated: state.auth.authenticate
};
};
return connect(mapStateToProps)(RequireAuth);
}
我想问为什么我的eslint显示错误unexpected token
,当我运行webpack时,它也返回错误unexpected token
?意外的令牌位置位于=
static propTypes
。我在Google上搜索,有些人像我一样做。
由于