error solved

Fix – assignment or function call and instead saw an expression no-unused-expressions in React


If you get an “assignment or function call and instead saw an expression no-unused-expressions in React” error, this article will help you to fix the issue.

The problem is mostly because you try to return a JSX element without a proper return syntax. This example can give you a similar error:

// incorrect implementation
const MyButton = () => {
   <button>Code Source</button>
}

To fix this, you have to return a JSX element the right way. See some examples below:

// using an explicit return
const MyButton = () => {
   return <button>Code Source</button>
}

// using short syntax return
const MyButton = () => ( 
   <button>Code Source</button>
)

Share on social media

//