Dynamically create elements in React Native
class Example extends React.Component {
constructor(props) {
super(props);
this.dataExample = this.props.dataExample;
}
render() {
let list = [];
this.dataExample.forEach((e,i)=>{
// need to add a key to each item in the list
list.push(
<View key={e + i}>
<Text>{e.title}</Text>
</View>
);
});
return (
<View>
{list}
</View>
);
}
}