React Native - Use a keyExtractor with FlatList

前端 未结 8 1176
暖寄归人
暖寄归人 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

    @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.

提交回复
热议问题