Cached Image component for Expo?


#1

Anyone knows of a image component that locally caches images and works with Expo? The ones I found all needed to link native modules.

Thanks!
Marcus


#2

Can you give an example of what you’re trying to do? Our asset system handles caching for you: https://docs.expo.io/versions/latest/guides/preloading-and-caching-assets.html


#3

I have lots of remote images in my app that are static (if the image changes, the uri will change, too).

The same images will be shown from seperate components and the same images will be shown with each and every new run of the app.

I want to make sure that each image is fetched only once per uri.


#4

Did you look at the link I posted? I think we cover your use case.


#5

https://facebook.github.io/react-native/docs/image.html and http://stackoverflow.com/questions/40719992/how-react-native-image-prefetch-works answered all questions I had.

Thanks for your help!
Marcus


#6

@minibbjd So am I correct in understanding that it only caches it so long as the component that prefetched it is mounted, i.e. if you restart the app, the cache is emptied?


#7

@minibbjd if you want there is an article that explains how to implement a cache in js https://medium.com/one-more-thing-studio/caching-your-images-on-react-native-with-expo-7bff361dbd54


#8

I just finished an expo component for image caching, you can check it out at https://medium.com/@wcandillon/5-things-to-know-about-images-react-native-69be41d2a9ee and https://github.com/wcandillon/react-native-expo-image-cache.