jobtoday / react-native-image-viewing

Tiny, purely TS, modal component for viewing images 🏙
https://exp.host/@antonkalinin/react-native-image-viewing
MIT License
880 stars 287 forks source link

Preload images for speed optimization #212

Open yerzhan-karatay opened 4 months ago

yerzhan-karatay commented 4 months ago

Hi there! Why do the images render every time the ImageViewing is visible, even if they've already been rendered? When a user closes and reopens ImageViewing, it loads the images from scratch without caching. How can I preload the images and then load them from the cache so I don't see the loader spinner all the time?

import ImageViewing from 'react-native-image-viewing';
...
<ImageViewing
        images={images}
        imageIndex={viewImageIndex ?? 0}
        key={item.uuid}
        visible={viewImageIndex !== null}
        onRequestClose={() => {
          setViewImageIndex(null);
        }}
      />