• Register
0 votes
1.1k 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?

6 5 3
7,540 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

 

9 7 4
38,600 points

Related questions

0 votes
2 answers 123 views
123 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 8 views
8 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 24.5k points
1 vote
1 answer 14 views
14 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 Shovo210 13.3k points
0 votes
1 answer 8 views
8 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 Shovo210 13.3k points
0 votes
1 answer 2 views
2 views
Problem: Please can anyone tell me the right procedure to do it? expected this to be used by class method
asked 5 days ago Ifra 24.4k points
0 votes
1 answer 675 views
675 views
Problem: I have recently started learning about React, Babel, JSX and JS. Now I am receiving an error from a babel if I tried to compile my JSX code into a JS code. Please find the error: &ldquo;Jsx value should be either an expression or a quoted jsx text.&rdquo ... out in my searching on interenet that prop values should be passed only between {}, but adding these to my code did not help me.
asked Aug 13, 2020 Raphael Pacheco 4.9k points
1 vote
1 answer 34 views
34 views
Problem : i'm using React router v^4.0.0, I've been having some trouble with react router. Router.js:43 Uncaught TypeError: Cannot read property 'location' of undefined at new Router (Router.js:43) at ReactCompositeComponent.js:295 at measureLifeCyclePerf ( ... .mountComponent (ReactReconciler.js:46) Any ideas on what I need to do to fix this? Thanks for your patience and help!!
asked Mar 21 Shovo210 13.3k points
1 vote
1 answer 5 views
5 views
Problem : I am new in javascript . When I binding delta in the constructor , I am getting the following error: Uncaught TypeError: Cannot read property 'setState' of undefined Code : class Counter extends React.Component { constructor(props) { super(props); this.state = { count : 1 }; ... >{this.state.count}</h1> <button onClick={this.delta}>+</button> </div> ); } } How to fix this error. Thanks!
asked Mar 20 Shovo210 13.3k points
0 votes
1 answer 9 views
9 views
Problem: I am very new to React and so facing this error: expected an assignment or function call and instead saw an expression no-unused-expressions
asked Mar 14 Wafa Abu Yousef 6.1k points