React Native: Can't fix FlatList keys warning

南笙酒味 提交于 2019-12-05 09:46:58

Looks like you need to change key to id as you write item.id in keyExtractor and be sure you have id and it's different for each component:

<FlatList
  data={this.props.tunes}
  keyExtractor={(item, index) => item.id}
  renderItem={({item}) => {
    <Item
      id={item.id} //instead of key
      title={item.title}
      composer={item.composer}
      year={item.year}
    />
  }}
/>

Or if you don't have unique key use keyExtractor={(item, index) => index}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!