简体   繁体   English

“无法将类作为函数调用”在非组件类中进行本地响应

[英]“Cannot call a class as a function” react native in non component class

Crawler.js: Crawler.js:

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

App.js: App.js:

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

var MyCrawler = new WebCrawler();

export default class App extends Component<Props> {

  render() {
    return (
...

But I'm getting “Cannot call a class as a function”. 但是我得到“无法将类作为函数调用”。 I've found multiple answers about this error. 我找到了有关此错误的多个答案。 Some of them tell to use new before the class name, which is what I'm doing, and the others say I must extend Component . 他们中的一些人告诉我在类名之前使用new ,这是我在做的,其他人则说我必须扩展Component But my Crawler class does nothing on the UI, why should I extend Component ? 但是我的Crawler类在UI上什么也不做,为什么我应该扩展Component

我想CookieStore也是一个类,所以您需要

  new CookieStore

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复另一个“不能将一个类称为函数”(非React) - How to fix another “Cannot call a class as a function” (non-React) 反应不能将 class 称为 function - react cannot call a class as a function Map function 在 class 组件反应原生 - Map function in class component react native 无法从读取到 Function 组件的 React Native 异步文件中获取数据(但在 Class 组件中有效) - Cannot get data from React Native asynchronous file reading into Function Component (but works in Class Component) 在闭包中调用类函数 React Native - Call class function inside a closure React native 在react class组件中调用Context的function - Call function of Context in react class component 如何在React Native中组件的render函数内部的对象内调用类? - How to call a class inside an object that's inside the render function of a component in React Native? react native:将类组件转换为带有钩子的函数组件的方法是什么? - react native: what is the way to transform the class component to a function component with hooks? 反应:TypeError:无法将类作为函数调用 - React: TypeError: Cannot call a class as a function TypeError:无法将类作为函数调用(React / Redux) - TypeError: Cannot call a class as a function (React/Redux)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM