Javascript 未捕获的TypeError:超级表达式必须为null或函数,而不是未定义的

Javascript 未捕获的TypeError:超级表达式必须为null或函数,而不是未定义的,javascript,reactjs,inheritance,ecmascript-6,Javascript,Reactjs,Inheritance,Ecmascript 6,我在继承和继承方面有点困难。这是我的代码设置: //This is the base class, this works (File 1) class Base extends React.Component {} export default Base //This is the firstchild, this also works (File 2) class FirstChild extends Base{} export default FirstChild //Thi

我在继承和继承方面有点困难。这是我的代码设置:

//This is the base class, this works (File 1)
class Base extends React.Component {}
export default Base

//This is the firstchild, this also works (File 2)
class FirstChild extends Base{}     
export default FirstChild 

//This results in the above TypeError (File 3)
class SecondChild extends FirstChild{}
export default SecondChild
奇怪的是,如果我把它改成:

class SecondChild extends Base
它起作用了

我已经看过这篇文章了: ,但仍然没有解决方案

我试图实现的是有一个具有某些功能的基本组件,另一个组件与基本组件有些相似,但覆盖了一些功能。最后,第三个组件构建在第二个组件的基础上,但再次覆盖第一个子组件中的一些函数

作为参考,我使用react:15.4.1


有什么建议吗?

建议您更喜欢组合而不是继承:也许您可以尝试以这种方式对其进行更改。这意味着您没有正确导入
FirstChild
,因为在定义
SecondChild
类时它是未定义的。向我们显示完整文件。Secondchild只是“从“..”导入FirstChild”。而Secondchild类扩展了FirstChild”。我还认为导入有问题,但当我从SecondChild构造函数中执行console.log(FirstChild)时,我会在控制台中获取类。如果存在循环依赖项,有时会发生这种情况,但是,如果没有一个可复制的示例,很难说。建议您更喜欢组合而不是继承:也许您可以尝试以这种方式对其进行更改。这意味着您没有正确导入
FirstChild
,因为在定义
SecondChild
类时,它是未定义的。向我们显示完整文件。Secondchild只是“从“..”导入FirstChild”。而Secondchild类扩展了FirstChild”。我还认为导入有问题,但是当我从SecondChild构造函数中执行console.log(FirstChild)时,我确实在控制台中获得了类。如果存在循环依赖项,有时会发生这种情况,但是如果没有可复制的示例,很难说。