Basic Example
suggest changeFor a classless React component:
function SomeComponent(props){
const ITEMS = ['cat', 'dog', 'rat']
function getItemsList(){
return ITEMS.map(item => <li key={item}>{item}</li>);
}
return (
<ul>
{getItemsList()}
</ul>
);
}
For this example, the above component resolves to:
<ul>
<li>cat</li>
<li>dog</li>
<li>rat</li>
</ul>
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents