If I have a list of uris:
[
https://example.com/pic1.jpg,
https://example.com/pic2.jpg,
https://example.com/pic3.jpg,
]
Change the state to switch from 0 to 1:
this.setState({ index: 1 })
And render that image:
<Image style={...} source={{ uri: images[this.state.index] }} />
When pic2.jpg shows up for the first time, it will have a very ugly flicker.
I have a scenario where I would expect a user to load the first image, then tap through to set the state to see the rest of the images. It would be nice to somehow preload the images, so they can display without a flicker.
There are libraries like https://github.com/DylanVann/react-native-fast-image which will work great AFTER the first load cause it will be cached, but I would like to preload the other uris while I am still on the first uri state.
Oh, it was staring me in the face. This happens to do exactly what I want:
https://github.com/DylanVann/react-native-fast-image#fastimagepreload-source--void
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With