• Register
0 votes
1.3k views

Problem :

I am using the reactjs.

When I try to run my code the browser says as below:

Uncaught TypeError: Super expression must either be null or a function, not undefined

The line used to compile my code:

browserify -t reactify -t babelify examples/temp.jsx  -o examples/public/app.js

Below is my code:

var myReact = require('react');
class MyHelloMessage extends React.Component {
render() {
return <div>Hello World !! </div>;
  }
}

Does anyone have any idea on the solution for my issue?

7.5k points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

·    Correct Class Names :

If you are sure that you must extend then please do it from the correctly named class, e.g. React.Component, and not React.component or React.createComponent, you may also need to upgrade your React version.

·     Upgrade React Version :

React is only supporting ES6-style classes since version 0.13.0 (please go through their official blog post on the support introduction here.Before that, while using:

class MyHelloMessage extends React.Component
you were trying to use ES6 keywords (extends) to the subclass from the class which was not defined using ES6 class. Because of this you were facing the strange behavior with the super definitions etc.

So, please TL;DR - update to React v0.13.x. 

·     Circular Dependencies

If one module is importing the another module and the other way around. In this scenario you must refractor the code to avoid it

 

38.6k points

Related questions

0 votes
2 answers 149 views
149 views
Problem : I am using the reactjs. When I run my code below my browser says: Uncaught TypeError: Super expression must either be null or a function, not undefined Any clues at all as to what is wrong with my code? First the line used to compile the code as below : ... var React = require('react'); class HelloMessage extends React.Component {   render() {     return <div>Hello World</div>;   } }
asked Jan 23, 2020 jwilliam 3.9k points
0 votes
1 answer 23 views
23 views
Problem: I am using reactjs. When I run the code below the browser says: Uncaught TypeError: Super expression must either be null or a function, not undefined
asked Mar 22 ummesalma 29.1k points
0 votes
1 answer 4 views
4 views
Problem: Super expression must either be null or a function.
asked Jun 28 akhi 125k points
0 votes
1 answer 38 views
38 views
Problem: Where could I find the answer to this problem? > Uncaught typeerror: cannot read property 'map' of undefined.
asked May 8 Irenka Kiri 85.5k points
1 vote
1 answer 412 views
412 views
Problem : I'm using React with ES7.I type anything in the input box of AuthorForm and I'm getting this error : Uncaught TypeError: Cannot read property 'state' of undefined HELP! I need help understanding this error. Thank you in Advance!
asked Mar 20 Sabbir Hossain 14.6k points
0 votes
1 answer 19 views
19 views
Problem: Can't find any solution, help : Super expression must either be null or a function not undefined.
asked Jun 20 Aurelia Maja 78.4k points
0 votes
1 answer 8 views
8 views
Problem: Is there anyone who knows the answer: : React super expression must either be null or a function, not undefined?
asked Jun 17 asha 121k points
0 votes
1 answer 275 views
275 views
Problem : I cannot call a bind from onchanged.I'm making list using onsenui and react.I get this : Typeerror: cannot read property 'bind' of undefined I couldn't figure out.... Does anyone can solve this?
asked Mar 21 Sabbir Hossain 14.6k points
0 votes
1 answer 11 views
11 views
Problem: Cannot read property 'type' of undefined?
asked Jul 19 Mezbah 130k points
0 votes
1 answer 9 views
9 views
Problem: Cannot read property 'bind' of undefined react?
asked Jul 6 Nahil 128k points