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>
)
})}
// for loop workaround in react render
[...Array(n)].map((_, index) => <span key={index}>element {index}</span>)
{arrayData.map(d => {
return (<Text>{d.element_key}</Text>);
})}
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)}
)
const n = 8;
{[...Array(n)].map((elementInArray, index) => (
<div className="" key={index}> Whatever needs to be rendered repeatedly... </div>
)
)}
data.forEach(
function(d){
forEachData += '<li>' + d.name + '</li>'
}
)
buttonsListArr = initialArr.map(buttonInfo => (
<Button ... key={buttonInfo[0]}>{buttonInfo[1]}</Button>
);
{
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