未捕获(承诺)TypeError:无法将类作为函数调用

赫马德里·达萨里

我最近将我的 babel 版本升级到最新版本。更新后,我的反应应用程序中的 babel 无法识别普通类,并且出现以下错误。

未捕获(承诺)TypeError:无法将类作为函数调用

.babelrc

{
  "presets": [
    "env", 
    "react"
  ],
  "plugins": [
    "transform-class-properties",
    "transform-object-rest-spread"
  ]
}

我的应用程序中与 babel 相关的库:

"babel-core": "^6.26.3",
"babel-eslint": "^8.2.6",
"babel-jest": "^22.4.3",
"babel-loader": "^7.1.5",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1"

babel 不理解这个类

CRUDTree.js

const resourceBoxWidth = 225;
const resourceBoxHeight = 85;
const halfBoxWidth = resourceBoxWidth / 2;
const halfBoxHeight = resourceBoxHeight / 2;
const urlLeftMargin = 10;
const urlFontSize = 12;
const fullPathFontSize = 10;
export default class{
  static resourceBoxWidth() { return resourceBoxWidth; }
  static resourceBoxHeight() { return resourceBoxHeight; }
  static halfBoxHeight() { return halfBoxHeight; }
  static halfBoxWidth() { return halfBoxWidth; }
}

APITree.js

import React, { Component } from 'react';
import CRUDTree from './CRUDTree';

class extends Component{
render(){
return(
  <CRUDTree data={
                [
                  this.state.treedata,
                  this.onClick,
                  {
                    x: this.state.offsetX,
                    y: this.state.offsetY
                  }
                ]}
              width={400} height={500}
              options={{
                border: "2px solid black",
                margin: {
                  top: 0,
                  bottom: 0,
                  left: 50,
                  right: 0
                }
              }
              } />
)
}
}
开发者馆

如果你CRUDTree是一个 React 组件(对我来说似乎是这样)那么你定义它是错误的。你错过了这一extends部分。

export default class extends React.Component {
    ....
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

ReactJS-未捕获的TypeError:无法将类作为函数调用

createSwitchNavigator-TypeError:无法将类作为函数调用

reactJS-TypeError:无法将类作为函数调用

React HOC:TypeError:无法将类作为函数调用

TypeError:无法将类作为函数调用(React / Redux)

React / Redux TypeError:无法将类作为函数调用

未捕获的TypeError:如果没有“ new”,则无法调用类构造函数ScratchStorage

未捕获的TypeError:如果没有“ new”,则无法调用类构造函数平台

未捕获(承诺)TypeError:生成不是函数

未捕获(承诺)TypeError:$不是函数

TypeError:运行Jest测试时无法将类作为函数调用

TypeError:部署到Netlify后无法将类作为函数调用吗?

TypeError:无法将类作为函数调用-ES6-Angular1.x-Webpack

未捕获(承诺)TypeError:无法读取未定义的属性“httpsCallable”(Firebase 函数问题)

错误:未捕获(承诺):TypeError:无法将属性“ isAdmin”设置为null

未捕获(承诺)TypeError:无法将属性'textContent'设置为null

未捕获(承诺)TypeError:d3.group不是函数

未捕获(承诺):TypeError:component.canDeactivate不是函数

未捕获(承诺):TypeError:this.auth.user $ .map不是函数

角度:错误:未捕获(承诺中):TypeError:Object(...)不是函数

错误:未捕获(承诺):TypeError:guard不是函数

未捕获(承诺)TypeError :(中间值).setAttribute不是函数

未捕获(承诺)TypeError:mostrarError不是函数。带钩

未捕获(承诺)TypeError:images.map不是函数

未捕获(承诺)TypeError:type.trim不是函数

react-redux错误无法将类作为函数调用

反应webpack设置-无法将类作为函数调用

Vue:无法将类作为函数Apex调用

在fetch'then'方法中调用拒绝函数时,“未捕获(承诺)”