reactrondev / react-native-web-swiper

Swiper-Slider for React-Native and React-Native-Web
213 stars 55 forks source link

Even if image state is removed, it is visible in the swiper. #105

Open yunyami0605 opened 10 months ago

yunyami0605 commented 10 months ago

images is string array state in react

If click the delete image state button, the image state is removed in the array, but the image is still visible on the swiper.

how to solve this problem?

<Swiper
    ref={ref}
    from={index}
    minDistanceForAction={0.1}
    onIndexChanged={(_index: number) => setIndex(_index)}
    controlsProps={{
      prevTitle: '',
      nextTitle: '',
      DotComponent:
        swiperType === 'dot'
          ? ({isActive}) => (
              <Circle
                width={'6px'}
                margin={'3px'}
                height={'6px'}
                backgroundColor={
                  isActive ? colors.fussOrange[0] : colors.scrim[60]
                }
              />
            )
          : () => <></>,
    }}
    controlsEnabled={
      swiperType === 'arrow' || images.length < 2 ? false : true
    }
    containerStyle={{
      width: imageWidth,
      height: imageWidth,
    }}>
    {images.map((item, i) => (
      <Image
        key={i.toString()}
        w={imageWidth}
        h={imageWidth}
        fallbackElement={
          <Center
            bgColor={colors.grayScale['10']}
            w={imageWidth}
            h={imageWidth}
          />
        }
        alt="post_img"
        source={{
          uri: `${item ?? ''}`,
        }}
      />
    ))}
</Swiper>