react native map array of objects code example

Example 1: how to map array of objects in react

[{
    name: 'Sam',
    email: '[email protected]'
 },
 {
    name: 'Ash',
    email: '[email protected]'
 }
].map( ( {name, email} ) => {
    return <p key={email}>{name} - {email}</p>
})

Example 2: how to map objects in react native

const api = { 'foo': 'bar', 'foz': 'baz'};
...
render() {
  return (
    Object.entries(api).map(([key, value]) => {
      return <View key={key}>{value}</View>
    });
  )
}

Example 3: how map work in react

{this.state.data.map((person) => <TableRow key = {shortid.generate()} data = {person} />)}

Example 4: react native map array of objects

var tmp_array = [
 { headline: "Test", text: "Test text", send_at: "test date" }
];