Supposing you have an array of 10 items in react native and you only want to display just 5 on a screen.
DATA
state = {
people: [
{firstName: Ben, lastName: Mark},
{firstName: Linda, lastName: Hanson},
{firstName: Arthur, lastName: Merlin},
{firstName: Jesus, lastName: Joshua}
]
}
VIEW
<ScrollView >
{
people.map((item, i) => {
return (
<View key={i} style={styles.user}>
<Card >
<ListItem
hideChevron={true}
title={item.firstName} {item.lastName}
/>
</Card>
</View>
);
})
}
</ScrollView>
Please how can i achieve this?
this.state.people, get's 5 people, then update the state withthis.setState({fivePeople: value});and then map over that array instead?