render: function() {
const elements = ['one', 'two', 'three'];
return (
<ul>
{elements.map((value, index) => {
return <li key={index}>{value}</li>
})}
</ul>
)
}
<div>
{items.map((item,index) => <ObjectRow key={index} name={item} />)}
</div>
// for loop workaround in react render
[...Array(n)].map((_, index) => <span key={index}>element {index}</span>)
var rows = [];
for (var i = 0; i < numrows; i++) {
rows.push(ObjectRow());
}
return tbody(rows);
function Example(num){
const output = new Array();
for(let i = 0; i< num ; i++){
output.push(<Component />)
}
return output;
}
return(
{get_comments(this.props.comments)}
)
for loop react
<tbody>
{objects.map((object, i) => <ObjectRow obj={object} key={i} />)}
</tbody>