Skip to content

Instantly share code, notes, and snippets.

@mathias5r
Created November 4, 2021 01:28
Show Gist options
  • Select an option

  • Save mathias5r/c1acc4ca3a86da212c2b025307283794 to your computer and use it in GitHub Desktop.

Select an option

Save mathias5r/c1acc4ca3a86da212c2b025307283794 to your computer and use it in GitHub Desktop.
generic component
const MyList = <T extends unknown>({items, onItemSelected}: MyListProps<t>): JSX.Element => (
<FlatList
data={items}
renderItem={({item}: {item: MyListItemProps<T>}) => (
<TouchableOpacity onPress={() => onItemSelected(item)}>
<Text>{item.text}</Text>
</TouchableOpacity>
)}
/>
);
@gabrielyotoo
Copy link

T is mistyped in MyListProps<t>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment