使用静态propTypes反应eslint和webpack意外标记

时间:2016-11-30 14:04:31

标签: reactjs webpack eslint

我有这段代码:

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上搜索,有些人像我一样做。

由于

0 个答案:

没有答案