how to create for loop of 10 items in react js code example
Example 1: react for loop
<tbody>
{[...Array(10)].map((x, i) =>
<ObjectRow key={i} />
)}
</tbody>
Example 2: react native jsx loop with number
Count wiil be my number value = 10;
const {Count} = props;
let list = Count=== undefined?10:Count;
let jsx = [];
for (let index = 0; index < list; index++) {
jsx.push('index'+index)
}
return (
<View>
<Text>{jsx.length}</Text>
{jsx.map(()=>(
<Text>{index}</Text>
))
}
</View>
)
==========================
if you try like this
jsx = new Array(list);
this will create array but jsx is not working
try your self