React-Native 遇到的坑

匿名 (未验证) 提交于 2019-12-03 00:14:01

一、错误日志:Warning: Failed child context type: Invalid child context virtualizedCell.cellKey of type number supplied to CellRenderer, expected string.
这个错误是在使用 RN官网推出最新的列表组件 FlatList 是出现的红色警告,出现这个错误可以正常运行,就是每次调试时看到它总觉得怪怪的,所以就查资料处理了,下面给出解决方案:

解决示例代码片段:

<FlatList
style={myStyle.newsList}
ref={(flatList)=>this._flatList = flatList}
ItemSeparatorComponent={this._separator}
renderItem={this._renderItem}
keyExtractor={(item, index) => index.toString()}
data={data}>
</FlatList>

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