const n = 8;
{[...Array(n)].map((elementInArray, index) => (
<div className="" key={index}> Whatever needs to be rendered repeatedly... </div>
)
)}
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>
{data.map(el => {
return (
<div>
<p>{el.content}</p>
</div>
)
})}
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)}
)
myLoopFunction() {
var myArray = [];
var i;
for (i = 0; i < this.state.events.length; i++) {
myArray[i] = (
<Event
time={this.state.events[i].time}
title={this.state.events[i].title}
/>
);
}
return myArray;
}
const n = 8;
{[...Array(n)].map((elementInArray, index) => (
<div className="" key={index}> Whatever needs to be rendered repeatedly... </div>
)
)}
<tbody>
{objects.map((object, i) => <ObjectRow obj={object} key={i} />)}
</tbody>
{
countryCodes.map(
({name,code,emoji}): React.ReactElement<any> => {
return (
<Picker.Item label={emoji+' '+name} value={code} key={name} />
);
},
)
}
use this in jsx anywhere use want to use