LoginSignup
1
1

More than 3 years have passed since last update.

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

Posted at

問題

FlatList使用時に以下の警告が出る
スクリーンショット 2020-04-15 13.37.32.png

解決

FlatListの各要素にkey属性を指定してあげれば良いと考えたが、警告が無くならない。以下の形式で、keyExtractorを利用すれば良い。


    <FlatList
        data={items}
        renderItem={({ item }) => (
          <ListItem
            key={item.key}
            attr={item.attr}
          />
        )}
        keyExtractor={(item, index) => index.toString()})
     />
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1