React-Native 遇到的坑

1、錯誤日誌:Warning: Failed child context type: Invalid child context virtualizedCell.cellKey of type number supplied to CellRenderer, expected string.
這個錯誤是在使用 RN官網推出最新的列表組件 FlatList 是出現的紅色警告,出現這個錯誤能夠正常運行,就是每次調試時看到它總以爲怪怪的,因此就查資料處理了,下面給出解決方案:this

解決示例代碼片斷:spa

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

調試

相關文章
相關標籤/搜索