I’m getting the below error in the functional component of the ReactJs application.

it’s giving this error

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

Bạn đang xem: React error


I wanted to use curly braces I had lớn add thereturntừ khoá, like so:

If You’re using JSX inside a function with curly braces you need to lớn modify it to parenthesis.

Wrong Code:

return =>


; );Correct Code

//Change Curly Brace To Paranthesis change lớn => ()return => (


; ));Class Component ExampleHere is the class component example, deeply observe sầu the return statement of the class component

import React from 'react';class Counter extends React.Component state = count: 0, ; formatCount() const count = this.state; // use a return statement here, it is a importent, return count === 0 ? 'Zero' : count; render() return( this.formatCount() Increment ); export default Counter;

Xem thêm: Làm Chả Giò Để Tủ Lạnh Ngày Tết, Cách Bảo Quản Nem Trong Tủ Lạnh Ngày Tết

Instead of

return ( this.formatCount() Increment )Use Below Code

return( this.formatCount() Increment )Basically use brace“(“in the same line of return like“return(“. It will fix this issue


In the above article, we underst& that a very comtháng lambda syntax typo mistakes lead lớn a difficult error, without understanding the phản hồi javascript syntax may lead khổng lồ such types of issues. So, I hope you find them helpful.


Buy me a coffee!
Angular CLIAuto-MapperbabelCode Analysisdata setData TableDateTimePickerEntity Framework CoreESLintLINQMicrosoft Squốc lộ Servernode modulesnpmObject-to-object Mappingpropsreact-reduxreact-testreduxRefsRegexSonarQubeSQLstate-managementType ScriptUnit TestingVisual StudioVisual Studio CodeWEB APIwebpackWindows Formswinforms
We use cookies to lớn ensure that we give sầu you the best experience on our trang web. If you continue to lớn use this site we will assume that you are happy with it.Ok