出現警告:Warning: flattenChildren(…): Encountered two children with the same key, .1:$4. Child keys must be unique; when two children share a key, only the first child will be used.
原因key出現問題了哪那邊出現問題了呢一般出現的比較多的就是flatlist.list等控件
比如我的
//flatlist佈局
renderView() {
return (
<View style={{ flex: 1 }}>
<FlatList
data={this.state.dataArray}
//es6寫法,es5寫法:this.renderRow
renderItem={this.renderRow.bind(this)}
//頭部試圖
// ListHeaderComponent={this.listHeaderComponet}
//分割線
//ItemSeparatorComponent={this._separator}
//下拉刷新
onRefresh={() => this._onRefresh()}
refreshing={this.state.isRefresh}
//加載更多
onEndReached={() => this._onLoadMore()}
onEndReachedThreshold={0.1}
//多列布局
numColumns={3}
//多列布局分割線
//columnWrapperStyle={{borderWidth:2,borderColor:'black',paddingLeft:20}}
keyExtractor={this.keyExtractor}
/>
</View>
);
};
keyExtractor(item: Object, index: number) {
return item.thumb
};
我的item中沒有’thumb‘這個字段所以我把它當初了key所以會報錯key爲空的錯誤,值喲改一下你的數據源中有的並且不唯一久好了.
警告 React Native--Animated:`useNativeDriver`is not supported because the native animated module is missing.
解決方法
如果你是手動集成的把node_modules中的react-native中的Libraies文件夾中的NativeAnimation中的RCTAnimation.xcodeproj拖入到項目中,然後把.a文件導入到Link Binary With Libaraies中如果不報錯運行久沒有警告了
如果時cocoapods集成直接在Podfile文件中加入‘RCTAnimation’然後pod install
如果報錯