相关疑难解决方法(0)

基本FlatList代码抛出警告 - React Native

FlatList似乎不起作用.我收到了这个警告.

VirtualizedList:缺少项目的键,确保在每个项目上指定键属性或提供自定义keyExtractor.

码:

<FlatList 
  data={[{name: 'a'}, {name: 'b'}]} 
  renderItem={
    (item) => <Text key={Math.random().toString()}>{item.name}</Text>
  } 
  key={Math.random().toString()} />
Run Code Online (Sandbox Code Playgroud)

react-native

114
推荐指数
5
解决办法
5万
查看次数

标签 统计

react-native ×1