I have an array of objects:
[
{
id: 1,
name: 'bill'
},
{
id: 2,
name: 'ted'
}
]
Looking for a simple one-liner to return:
[
{
value: 1,
text: 'bill'
},
{
value: 2,
text: 'ted'
}
]
So I can easily pump them into a react dropdown with the proper keys.
I feel like this simple solution should work, but I'm getting invalid syntax errors:
this.props.people.map(person => { value: person.id, text: person.name })
person => ({...
. In other words, enclose the object literal in parens. Otherwise JS thinks it's the beginning of a block. – Gearhart