Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get SyntaxError: Assigning to rvalue?

I have a map() and I want to pass two parameters:

  1. a string
  2. a function

Example code:

{
  values.map((workflow, totalWorkflow()) => {
    return <WorkflowSingle key={ workflow } workflow={ workflow } />
  })
}

Why do I get this error: SyntaxError: Assigning to rvalue

like image 991
Vlad Stan Avatar asked Apr 26 '16 22:04

Vlad Stan


2 Answers

You get rvalue error, when you use = instead of == in a condition checking block.

like image 87
Ignatius Andrew Avatar answered Nov 13 '22 13:11

Ignatius Andrew


If your map function is the Array.prototype.map function, you passed wrong parameters to the function, map accepts callback and second optional parameter, like this:

arr.map(callback[, thisArg])

For your case:

values.map(function(x) {
    return <WorkflowSingle key = { x.workflow } workflow = { x.workflow } />
});  
like image 7
isvforall Avatar answered Nov 13 '22 13:11

isvforall