jobtoday/react-native-image-viewing

should reset internal imageIndex state after close

themez opened this issue · 1 comments

I have a image list, click a specific item in the list would trigger image viewing modal open and show the clicked image.

import ImageView from 'react-native-image-viewing'

function MyImageViewer(props){
  return <ImageView
      images={props.images}
      imageIndex={props.imageIndex}
      visible={props.visible}
      swipeToCloseEnabled={true}
      HeaderComponent={(imageIndex) => <Text>{imageIndex}</Text>}
      FooterComponent={(imageIndex) => <Text>{imageIndex}</Text>}
    />
}

The abnormal case is like that:

  1. click the first image to open image viewing modal and the modal presents image-0
  2. swipe to second image, the modal presents image-1
  3. close the image viewing modal
  4. click the first image to open image viewing modal
  5. the modal presents image-0, but the header and foot component received older imageIndex param: 1

Thanks for the fix man, wish this package was actually maintained