Warning: flattenChildren(...)警告解决方案

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_30211165/article/details/79917460

出现警告: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
如果报错

猜你喜欢

转载自blog.csdn.net/qq_30211165/article/details/79917460