Firstly, if you"re particular that you"re expanding from the correctly named class, e.g. React.Component, not React.component or React.createComponent, you may need to upgrade your reaction version. View answers below for an ext information top top the classes to prolong from.

You are watching: Uncaught typeerror: super expression must either be null or a function, not undefined


Error :-

reactjs giving error Uncaught TypeError: supervisor expression have to either it is in null or a function, not undefined

Upgrade React

React has actually only sustained ES6-style classes since version 0.13.0 (see their main blog short article on the support development here.

Before that, once using:

class HelloMessage extends React.Component

you were attempting to use ES6 keywords (extends) to subclass native a class which wasn"t identified using ES6 class. This was most likely why you were running right into strange behaviour with super definitions etc.

So, yes, TL;DR - upgrade to react v0.13.x.

Circular Dependencies

This can additionally occur if you have circular income structure. One module importing another and the other method around.

Lets look at the culprits (that I have come across so far) that cause this error in detail.

1. Forgotten export

The very first culprit is usually that you have actually forgotten to export the component that you space trying come use and also hence reaction finds that the ingredient you space trying to prolong from is undefined . This is simple to find and also fix issue.

2. Utilizing a default export incorrectly

If a ingredient is exported v the default keyword climate it have to be imported together a default import and also not together a named import.

For example if her export declare is export default Foo, climate the correct way to income this ingredient is import Foo indigenous "./Foo" and also not import Foo from "./Foo" . The latter import declare is for named exports.

3. Circular Dependencies

This is a an often missed culprit which ns came across recently in one of the jobs I was functioning on. After ~ going into the depths of the google search rabbit hole, I ultimately came throughout a ridge overflow price that melted some irradiate on why i was still acquiring the error in-spite the the component gift exported / imported correctly.

See more: Noah Cyrus And Miley Cyrus Cheerleading, Interesting Facts About Miley Cyrus' Childhood

If you have actually dependencies of a cyclic nature like shown below, the will an outcome in this error:

class A expand B class B extend C class C extends A

This is all aboutreactjs offering error Uncaught TypeError: super expression have to either it is in null or a function, not undefined.

Reference :-