Superclass constructor invocation should be in constructor body

maxwell picture maxwell · Sep 22, 2015 · Viewed 7.2k times · Source

I write React class constructor use es6, but there is a red highlight error in webstorm9 editor here is the part of code:

class AssetSelectDialog extends React.Component {
static propTypes = {
    data: React.PropTypes.any,
    pageState: React.PropTypes.string,
    pageStatus: React.PropTypes.string,
    handleCancel: React.PropTypes.func,
    handleSave: React.PropTypes.func
};

constructor(props) {
    super(props);
    this.PAGE_STATUS = {
        SHOW: 'SHOW',
        SELECT: 'SELECT'
    };
    this.state = {
        data: this.props.data || {},
        pageState: this.props.pageState || CONST.STATUS.EDIT,
        pageStatus: this.props.pageStatus || this.PAGE_STATUS.SHOW 
    };
}

there error was found in super(props); and the message is Superclass constructor invocation should be in constructor body. the code is run ok in babel., how can I fixed it?

Answer

lena picture lena · Sep 22, 2015

It's a bug in WebStorm, WEB-14601 is fixed in WebStorm 10.0.4