Skip to content

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

@yunyami0605

Description

@yunyami0605

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions