简体   繁体   中英

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

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 (
...

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 . But my Crawler class does nothing on the UI, why should I extend Component ?

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

  new CookieStore

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM