React Native - Use a keyExtractor with FlatList

前端 未结 8 1167
暖寄归人
暖寄归人 2021-02-01 14:05

I have been getting the:

\"VirtualizedList: missing keys for items, make sure to specify a key property on an item or provide a custom keyExtractor\"

相关标签:
8条回答
  • 2021-02-01 15:03

    i do this and work for me:

    keyExtractor={(item, index) => 'key'+index}
    
    0 讨论(0)
  • 2021-02-01 15:03

    @Sarantis Tofas has the correct answer. Solved it for me! Two additional notes based on the comments:

    1. If you use index then make sure to use index.toString() or you'll get a different warning (Failed child context type - type number supplied to CellRenderer expected string).
    2. FlatList will work with index by default if you don't have key properties or a keyExtractor defined, but it will still throw a warning.
    0 讨论(0)
提交回复
热议问题