import * as Contacts from 'expo-contacts'; import * as React from 'react'; import { FlatList, FlatListProps, ListRenderItem, StyleProp, ViewStyle } from 'react-native'; import ContactsListItem from './ContactsListItem'; type Props = { onPressItem: (id: string) => void; style?: StyleProp; data: Contacts.Contact[]; } & Pick< FlatListProps, Exclude, 'renderItem' | 'keyExtractor' | 'data'> >; export default function ContactsList({ data, style, onPressItem, ...props }: Props) { const renderItem: ListRenderItem = React.useCallback( ({ item }) => ( onPressItem?.(id)} /> ), [onPressItem] ); return ( {...props} style={[{ flex: 1 }, style]} keyExtractor={(item) => item.id!} data={data} renderItem={renderItem} /> ); }