Source:  Twitter logo

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

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

25 users liked answer #0dislike answer #025
Ignatius Andrew profile pic
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 } />
});  
7 users liked answer #1dislike answer #17
isvforall profile pic
isvforall

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
    }
}
0 users liked answer #2dislike answer #20
godblessstrawberry profile pic
godblessstrawberry

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(>=)

-4 users liked answer #3dislike answer #3-4
Olutobi Olusesi profile pic
Olutobi Olusesi

Copyright © 2022 QueryThreads

All content on Query Threads is licensed under the Creative Commons Attribution-ShareAlike 3.0 license (CC BY-SA 3.0).