【问题标题】:“Cannot call a class as a function” react native in non component class“不能将类作为函数调用”在非组件类中反应原生
【发布时间】:2018-03-25 17:06:14
【问题描述】:

Crawler.js:

export class WebCrawler {
    cookie_stores = [CookieStore(sisgrad_domain)];
...

App.js:

import { WebCrawler } from './crawler.js';

var MyCrawler = new WebCrawler();

export default class App extends Component<Props> {

  render() {
    return (
...

但我得到“不能将类调用为函数”。我找到了有关此错误的多个答案。他们中的一些人告诉在类名之前使用new,这就是我正在做的事情,而其他人说我必须扩展Component。但是我的 Crawler 类在 UI 上什么也没做,我为什么要扩展 Component

【问题讨论】:

  • 可能导入WebCrawler ?
  • @JonasW。我已经编辑了,名称错误。但是眼睛好,谢谢

标签: javascript react-native ecmascript-6


【解决方案1】:

我猜CookieStore 也是一个类,所以你需要这样做

  new CookieStore

【讨论】:

    猜你喜欢
    • 2023-03-08
    • 2018-09-10
    • 1970-01-01
    • 1970-01-01
    • 2017-10-21
    • 2019-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多