Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/456.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript React Native-超级表达式必须为null或函数_Javascript_Reactjs_React Native_Super_Superclass - Fatal编程技术网

Javascript React Native-超级表达式必须为null或函数

Javascript React Native-超级表达式必须为null或函数,javascript,reactjs,react-native,super,superclass,Javascript,Reactjs,React Native,Super,Superclass,我想构建一个包含多个方法的超类,因为我想从不同的类调用它们。此外,我还有减少代码的好处 但是,我收到错误消息“超级表达式必须为null或函数” 这是我的一个类,我想在其中从SuperScreen.js文件调用函数super.interface(): import React from "react"; import { SuperScreen } from "./SuperScreen"; export default class HomeScreen extends SuperScreen

我想构建一个包含多个方法的超类,因为我想从不同的类调用它们。此外,我还有减少代码的好处

但是,我收到错误消息“超级表达式必须为null或函数”

这是我的一个类,我想在其中从SuperScreen.js文件调用函数
super.interface()

import React from "react";
import { SuperScreen } from "./SuperScreen";

export default class HomeScreen extends SuperScreen {
  constructor(props) {
    super(props);
    this.state = {
      isLoading: true,
      data: null,
      key: 15
    };
  }

render() {
    return super.interface();
  }
}
我的超级屏幕.js

import React, { Component } from "react";

export default class SuperScreen extends Component {
  constructor() {}

  interface() {...}
}
但是,我仍然得到消息
超级表达式必须为null或函数。为什么以及如何修复它


向您致意并感谢

您的导入有点混乱。 从
SuperScreen
import中删除花括号,因为您默认导出了SuperScreen类

import SuperScreen from "./SuperScreen";
或者改为更正导出

export class SuperScreen extends Component

从SuperScreen组件构造函数中调用super,或者完全避免使用构造函数,但两者都不起作用…谢谢。工作!-花括号是什么意思?对不起,我是说花括号。谢谢。但我为什么要移除它们?