4 ms·
Generally speaking, I do not recommend this pattern. My preference is to handle enumeration within a function, for example: <ul> {this.listItems(items)}
by supernintendo 11y ago
Generally speaking, I do not recommend this pattern. My preference is to handle enumeration within a function, for example:
<ul>
{this.listItems(items)}
</ul>
Then, within a function implemented on the same component:
listItems: function(items) {
items.map((item) => {
return <li>{item.name}</li>
});
}
- freekh 11y agoIs it just me, or is the return missing in the `function` (or am _I_ missing something :)? Not important of course, just pointing it out...
- supernintendo 11y agoGood catch! I wrote that example in a hurry on my lunch break so I take accountability for the mistake.
- gberger 11y agoIf you omit the {} you can then also omit the return. https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions https://developer.mozilla.org/en/docs/Web/JavaScript/Referen...