kfiroo / react-native-cached-image

CachedImage component for react-native
MIT License
938 stars 470 forks source link

allow passing urlCache as prop to ImageCacheProvider #90

Open bajceta opened 6 years ago

bajceta commented 6 years ago

react-native-clcasher fetches data from the AsyncStorage every time, and there seems to be a performance penalty in doing that. In our case it caused the renderLoader to be executed everytime. I made a small wrapper over clcacher that stores values in memory for faster fetching, while persistently caching them with clcasher. https://github.com/bajceta/react-native-in-memory-persisted-cache/blob/master/index.js

This PR enables passing 'urlCache' to ImageCacheProvider in order to use this implementation.

Example of usage:

import MemoryPersistedCache from 'react-native-in-memory-persisted-cache';
...
 <ImageCacheProviderPreloaded urlCache={MemoryPersistedCache}>                                                                                                                                
kfiroo commented 6 years ago

@bajceta Amazing PR! Thanks! Please see my comments inline :)