react map return component code example
Example 1: map function in react
function NameList() {
const names = ['Bruce', 'Clark', 'Diana']
return (
<div>
{names.map(name => <h2>{name}</h2>)}
</div>
)
}
Example 2: how map work in react
{this.state.data.map((person) => <TableRow key = {shortid.generate()} data = {person} />)}
Example 3: react native map repeate
render() {
return (
<View style={styles.container}>
{places.map((place) =>
<View>
<Text>{place.title}</Text>
<Text>{place.description}</Text>
</View>)}
</View>
);
}