基于react开发的项目在启动过程中,提示?A decorated export must export a class declaration报错,如下图所示:
上面是一个react hoc高阶组件,es6装饰器的语法是要包裹class组件的,所以要改成以下这种写法就ok了;
export default function WithOperateTab(WrappedComponent) {
@withRouter
@withAliveScope
class WrapperComponent extends PureComponent {
openTab = (url) => {
if (url) {
const { tabKey } = getKeyName(url)
this.props.history.push(url)
setTimeout(() => {
const cachingNodes = this.props.getCachingNodes(tabKey)
if (cachingNodes.find((item) => item.cacheKey === tabKey)) {
this.props.refresh(tabKey)
}
}, 100)
}
}
}
return WrapperComponent;
}