This content originally appeared on CodeSource.io and was authored by Pandu Rijal Pasa
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>
)
The post Fix – assignment or function call and instead saw an expression no-unused-expressions in React appeared first on CodeSource.io.
This content originally appeared on CodeSource.io and was authored by Pandu Rijal Pasa
Pandu Rijal Pasa | Sciencx (2021-02-22T12:42:12+00:00) Fix – assignment or function call and instead saw an expression no-unused-expressions in React. Retrieved from https://www.scien.cx/2021/02/22/fix-assignment-or-function-call-and-instead-saw-an-expression-no-unused-expressions-in-react/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.