我使用ES6编写React类构造函数,但在WebStorm9编辑器中出现了红色高亮错误。
以下是代码的一部分:
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
};
}
在super(props);
中发现了错误,错误信息为Superclass constructor invocation should be in constructor body
。代码在babel中可以正常运行,我该如何修复它?