React Native:超过最大更新深度

时间:2020-08-22 01:18:10

标签: react-native

我正在向React Native 0.62.2应用程序添加滑动组件。这是返回码:

import React, { useLayoutEffect, useState, useEffect, useContext} from 'react';
import {View, Image, StyleSheet, ScrollView, Dimensions,  TouchableOpacity, SafeAreaView, Alert, TouchableWithoutFeedback } from 'react-native';
import {Button, Left, Right, Body, Label, Textarea, Item, Icon, Input, Text, Card, CardItem, Header, Container, Content, Form } from 'native-base';
import FastImage from 'react-native-fast-image';
import { FlatList, RectButton, PanGestureHandler, PinchGestureHandler, State } from 'react-native-gesture-handler';
import Animated, { useValue } from "react-native-reanimated";

导出默认功能Swipe({route,navigation}){ .... 返回(

        <Container style={styles.container}>
            
            <Header>
                <Left>
                    <Button transparent onPress={() => navigation.push("Itie")}>
                    <Icon name="arrow-back-sharp" />
                    </Button>
                </Left>
                
                <Right>
                {/* <Button onPress={() => helper.handleAddPicture(addImages, 'photo', false, null)} transparent>
                    <Icon name='add-circle-outline' />
                </Button>
                    <Button onPress={clickSave} disabled={!post} transparent>
                        <Icon name='checkmark-outline' />
                    </Button>  */}
                </Right>
            </Header>
            <PanGestureHandler 
                onGestureEvent={handleGesture} 
                onHandlerStateChange={handleGesture}
                minPointers={1}
                maxPointers={1}>
                <Animated.View style={StyleSheet.absoluteFill}>
                    <Animated.View style={[{width:width*images.length, flexDirection:"row", height:height}, aniStyle ]}>
                    {images.map((img_source) => (  //<<==error of max update depth reached after adding this map. there are images.length=3
                    <FastImage 
                        source={{uri:img_source.path}} 
                        resizeMode={FastImage.resizeMode.cover} 
                        key={img_source.fileName}
                        style={{
                            width:width, 
                            height:height, 
                            verticalAlign:0,
                            paddingTop:0,
                        }}
                    />))}
                    </Animated.View>
                </Animated.View>
            </PanGestureHandler>
            
                              
        </Container>

    
    );

};

}

问题在于,在传入的images上添加地图后,它将引发max update depth exceeded的错误。添加的代码在这里有什么问题?

enter image description here

0 个答案:

没有答案