Why Do I Get Syntaxerror: Assigning to Rvalue?

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

4

4 Answers

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

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 } />
});  
2

For those who came here getting this eslint error in a new project with completely valid code - you need to provide the config to eslint, e.g.:

{
    "parserOptions": {
        "ecmaVersion": 2017
    },
    "env": {
        "es6": true
    }
}

Look at your comparison operator. They are in the wrong direction (=>). Put the equal to sign always at the right and your less or greater than always at the left of your assignment operator(>=)

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Marcus Vance
Author

Marcus Vance

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.