React-Native 遇到的坑

转载请注明出处:https://blog.csdn.net/demokui/article/details/79956313

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

(flatList)=>this._flatList = flatList}
     ItemSeparatorComponent={this._separator}
     renderItem={this._renderItem}
     keyExtractor={(item, index) => index.toString()}
     data={data}>

你可能感兴趣的:(React-Native)