我确实得到了这个线路使用standardJS时出现的一个standardJS校线错误。所以我的CI失败了。
我不明白这句话有什么问题。我怎么才能解决这个问题?
export default (App) => {
return class Apollo extends React.Component {
static displayName = 'withApollo(App)' // <--
static async getInitialProps (ctx) {
// ...
}
}发布于 2018-11-12 07:58:23
如果这是标准的javascript,那么错误是类只能包含函数,而不能包含属性。
正确的语法应该是:
class Apollo extends React.Component {
static async getInitialProps (ctx) {
// ...
}
Apollo.displayName = 'withApollo(App)';
export default (App) => {
return Apollo;
}如果您正在使用建议的(但尚未实现或批准) ES7/ES8类属性,那么eslint可能还不支持它。
如果与最初的问题不同,您需要使用App参数,只需在要导出的函数中这样做:
class Apollo extends React.Component {
static async getInitialProps (ctx) {
// ...
}
export default (App) => {
Apollo.displayName = `withApollo(${App})`;
return Apollo;
}https://stackoverflow.com/questions/53256854
复制相似问题