Expected an assignment or function call and instead saw an expression(error)

Viewed 35
let a=50, b=150; 
let elements= [ { data: { id: 'root ', label: 'SANIANJUM' }, position: { x: a, y: b } }, ]; let username = "SANIANJUM"; 
elements.push({ data: { id: 'two', label: 'Node 2' }, position: { x: 150, y: 100 } },) 
elements.push({ data: { source: 'one', target: 'two', label: 'Edge from Node1 to Node2' } },);

//can't push to my elements array ![Using async to fetch data here][2] [2]: https://i.stack.imgur.com/R3R7O.png

1 Answers

The React.js error "Expected an assignment or function call and instead saw an expression" occurs when we forget to return a value from a function. To solve the error, make sure to explicitly use a return statement or implicitly return using an arrow function.

Here is the screenshot of issue

Related