expected assignment or function call no-unused-expressions ReactJS

0 votes

This is my code:

class Game extends Component 
{
  constructor() 
  {
    super()
    this.state = {
      speed: 0
    }
    //firebaseInit()
  }
  render()
  {
    return 
    (
      <div>
        <h1>The Score is {this.state.speed};</h1>
      </div>
    )
  }
}

export default Game;

I am getting this error when I execute the above code:

Expected an assignment or function call and instead saw an expression  no-unused-expressions

What is the problem with the code? 

May 18, 2022 in Others by Kichu
• 19,040 points
3,091 views

1 answer to this question.

0 votes
The problem is that you have put the bracket of return on the next line. This makes the interpreter thinks that you return undefined and don't check your next line. To solve this just put your opened bracket on the same line as the return.

I hope this helps you.
answered May 20, 2022 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer
0 votes
0 answers

Quectel EC20 LTE Module doesnt show me incoming call or sms

I'm using an LTE Module QUECTEL EC20 ...READ MORE

Apr 4, 2022 in Others by Kichu
• 19,040 points
767 views
0 votes
0 answers

what does bash: /home/XXX/.rvm/scripts/rvm: No such file or directory mean?

I was installing the ruby on rails ...READ MORE

May 26, 2022 in Others by Ashwini
• 5,430 points
958 views
0 votes
0 answers

React: Expected an assignment or function call and instead saw an expression

I want to fix lint error at ...READ MORE

May 23, 2022 in Others by Kichu
• 19,040 points
2,549 views
0 votes
1 answer

How to convert HTML to JSX (React.js)

You can use https://magic.reactjs.net/htmltojsx.htm which is an online HTML ...READ MORE

answered Aug 10, 2022 in HTML by Deepak
• 980 points
1,560 views
0 votes
0 answers

Calendar React JS

I have a homework to make a ...READ MORE

Jan 27, 2023 in Others by Tejashwini
• 3,820 points
718 views
0 votes
1 answer

How can I remove a port from url for node app using nginx

If you run your node server on ...READ MORE

answered Apr 10, 2018 in DevOps on Cloud by ajs3033
• 7,300 points
4,028 views
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP