List with map function | without flatlist
App.js:
import React from 'react';
import { ScrollView, StyleSheet, Text, View } from 'react-native';
const App=()=>{
const users=[
{
id:1,
name:"Kavita",
},
{
id:2,
name:"Diksha",
},
{
id:3,
name:"Krishan",
},
{
id:4,
name:"Bhavesh",
},
{
id:5,
name:"Bhavesh",
},
{
id:6,
name:"Raj",
},
{
id:7,
name:"Ram",
},
{
id:8,
name:"Shyam",
},
{
id:9,
name:"Brijesh",
},
{
id:10,
name:"Mohan",
}
]
return(
<View>
<Text style={{ fontSize: 30, backgroundColor:'green', color:'white' }}>List with map function</Text>
<ScrollView>
{
users.map((item)=><Text style={styles.TextBox}>{item.name}</Text>)
}
</ScrollView>
</View>
);
};
const styles=StyleSheet.create({
TextBox:{
color:'white',
backgroundColor:'blue',
marginBottom:10,
padding:10,
fontSize:50
}
}
)
export default App;
Comments
Post a Comment