Wednesday, May 27, 2020

React Native Part 4: Lists (Code Snippets)


import React, {useState} from 'react';
import { StyleSheet, Text, View } from 'react-native';

export default function App() {
  const [contacts,setContact] = useState([
    {name: 'Shalvin', key:1},
    {name: 'Joy', key:2},
    {name: 'Arun', key:3}
  ]);
  return (
    <View style={styles.container}>
    <View>
     {contacts.map((contact) => (
       <Text key={contact.key}>{contact.name}</Text>
     ))} 
    </View>
    </View>
  );  
}


No comments:

Post a Comment