1
2Count wiil be my number value = 10;
3
4
5
6const {Count} = props;
7 let list = Count=== undefined?10:Count;
8 let jsx = [];
9 for (let index = 0; index < list; index++) {
10 jsx.push('index'+index)
11 }
12
13 return (
14 <View>
15 <Text>{jsx.length}</Text>
16 {jsx.map(()=>(
17 <Text>{index}</Text>
18 ))
19 }
20 </View>
21
22 )
23
24==========================
25
26
27if you try like this
28jsx = new Array(list);
29
30this will create array but jsx is not working
31
32try your self
33
1import React from 'react';
2import './App.css';
3
4
5let items=['Item 1','Item 2','Item 3','Item 4','Item 5'];
6let itemList=[];
7items.forEach((item,index)=>{
8 itemList.push( <li key={index}>{item}</li>)
9})
10function App() {
11
12 return (
13 <>
14
15 <h2>This is a simple list of items</h2>
16 <ul>
17 {itemList}
18 </ul>
19 </>
20 );
21}
22
23export default App;
24