Answers for "WARN VirtualizedList: missing keys for items, make sure to specify a key or id property on each item or provide a custom keyExtractor."

1

WARN VirtualizedList: missing keys for items, make sure to specify a key or id property on each item or provide a custom keyExtractor.

Simply do this:

<FlatList 
  data={[{name: 'a'}, {name: 'b'}]} 
  renderItem={
    ({item}) => <Text>{item.name}</Text>
  } 
  keyExtractor={(item, index) => index.toString()}
/>

reference:
https://facebook.github.io/react-native/docs/flatlist.html#keyextractor
Posted by: Guest on August-25-2021

Code answers related to "WARN VirtualizedList: missing keys for items, make sure to specify a key or id property on each item or provide a custom keyExtractor."

Browse Popular Code Answers by Language