• Register
0 votes
966 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 101 views
101 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 363 views
363 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
0 votes
2 answers 1.6K views
1.6K 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 Nov 18, 2019 peterlaw 6.9k points
0 votes
2 answers 304 views
304 views
Problem : I often face below error after making the trivial React example page: &ldquo;Uncaught Error: Invariant Violation: _registerComponent(...): Target container is not a DOM element.&rdquo; Below is my code: /** The @jsx React.DOM */ 'use strict'; var MyReact = require('react'); ... > <head>  <script src="/mybundle.js"></script> </head> <body> </body> </html> What does the above error mean?
asked Jan 7, 2020 alecxe 7.5k points
0 votes
1 answer 4 views
4 views
I have the following index.js file: const React = require('react'); let App = React.createClass({ render: () => { return ( <div> Hello,this is jsx! </div> ); } }); module.exports = App; This code renders the following HTML: <!DOCTYPE html> ... [as engine] (/Users/xinhengs/Desktop/QunarDevs/qact/server/node_modules/express-react-views/index.js:46:32) Please help me figure out what&rsquo;s going on.
asked 3 days ago khaled 280 points
1 vote
1 answer 313 views
313 views
Problem: I wrote a program in which gives me the following error : TypeError: startswith first arg must be bytes or a tuple of bytes, not str The program I wrote is: def allFasta(filename): xd = open(filename, 'yb') headers = "" sequence = "" while True: ... ("youn.xd") Why is this type error message is appearing for this program. Is there any problem with my programs arguments? Thanks in advance.
asked Jun 11, 2020 samhaz 5k points
0 votes
1 answer 1.9K views
1.9K views
Problem : I am facing the issue in passing a function as a parameter to another function as follows typeerror: int() argument must be a string, a bytes-like object or a number, not 'nonetype'
asked Nov 18, 2019 peterlaw 6.9k points