1.錯(cuò)誤日志:Warning: Failed child context type: Invalid child context virtualizedCell.cellKey of type number supplied to CellRenderer, expected string
原因:使用FlatList出現(xiàn)的紅色錯(cuò)誤警告搜骡,原因是FlatList的每一個(gè)Item都需要一個(gè)唯一的key來(lái)標(biāo)記識(shí)別桂塞,并且此標(biāo)記的value值可接受類(lèi)型是string
治宣。
處理方法:將keyExtractor
此值轉(zhuǎn)換為string
處理代碼:
<FlatList
data={this.state.dataList}
renderItem={this.renderCell}
keyExtractor={this.keyExtractor}
onRefresh={this.requestData}
refreshing={this.state.refreshing}
ListHeaderComponent={this.renderHeader}
/>
keyExtractor = (item: Object, index: number) => {
return item.id.toString()
}
2.錯(cuò)誤:React-Navigation使用出現(xiàn)Warning: isMounted(...) is deprecated in plain Javascript Classes. Inst
原因:源代碼內(nèi)部有被React
放棄維護(hù)棄用的方法
處理方法:在index.js
中引入以下代碼,忽略警告
處理代碼:
import { YellowBox } from 'react-native';
YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated', 'Module RCTImageLoader']);
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者