• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes

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

6 5 3
6,930 points

2 Answers

0 votes

Solution :

This error comes up because you have put the bracket of return on the next line. This is a common mistake if you are familier with js without semicolons and you use a style where you put opened braces on the next line.

But the nnterpreter thinks that you return undefined and will not check your next line. So the return operator thing.

So to get rid of this issue you need to put your opening bracket on the same line with the return.

9 7 4
38,600 points
0 votes

The “expected an assignment or function call and instead saw an expression” error encounters in javascript when an expression return value with no effect.


In the following example, we have a conditional statement that has to evaluate true but has no effect on the program.

var x =1;

x ====1; //Evaluates to be “true”.

Another example:

var x = 5;

var y = 3 * 7;

var z = “cake” .length * 9;


The values on the right-hand side of the assignment operator are called expression. The expressions can not stand alone. The warning message can occur that you have forgotten the variables that would normally assign that the expressions value tp.

Function call:

A function call is something like console.log(“HI”). This function call also called an expression.

Missing Semicolons:

In some cases semicolons can also be omitted. But it is suggested to put them wherever the yellow warning sign says that a semicolon is missing. You can remove them later when you understand exactly under which conditions these semicolons can be omitted. If the removal of semicolon does not produce a warning, then it means that the semicolon does not belong at that place.


Semicolons in the wrong places can create bugs that are hard to find.

11 5 1
3,890 points

Related questions

0 votes
2 answers 78 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 jwilliam 3.9k points
0 votes
1 answer 758 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 ... Component { render() { return <div>Hello World !! </div>; } } Does anyone have any idea on the solution for my issue?
asked Dec 7, 2019 alecxe 7.6k points
0 votes
1 answer 56 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 Raphael Pacheco 4.9k points
0 votes
2 answers 72 views
Problem : I am trying to learn React JS. I have written a code for component . I also have the data that I get from a Data Base, and whose current state (myDB) I dispatch.I am trying to use data from myDB object and then want to display some of the ... a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons How to fix this issue ?
asked Feb 22 mphil 2.3k points