I generally understand how ES6 function arrows work. I also understand that at times parentheses can be used to implicitly return an object. However, in terms of React/JSX, are the parentheses necessary in the following?
class Contactlist extends React.Component {
render() {
const people = [
{ name: 'Tyler' },
{ name: 'Karen' },
{ name: 'Richard' }
]
return <ol>
{
people.map(
// are the parentheses necessary here??
person => (<li key={person.name}>{person.name}</li>)
)
}
</ol>
}
}
Or is it simply okay to do the following?
...
return <ol>
{
people.map(
person => <li key={person.name}>{person.name}</li>
)
}
</ol>
...
So, I guess what I should really be asking about is whether jsx elements are considered js objects. If so, then the parentheses are probably being used to implicitly return them from the fat arrow function.