kfiroo / react-native-cached-image

CachedImage component for react-native
MIT License
940 stars 468 forks source link

after i clean cache, it not refresh new image on flat list #86

Open ruoyuruoshui opened 7 years ago

rogoja commented 6 years ago

+1

rogoja commented 6 years ago

here's how I solved this problem:

defaultImageCacheManager.getCacheInfo().catch(() => {
            defaultImageCacheManager.clearCache();
        });

If you do not have access to the cache, clear the cache

chrusart commented 6 years ago

This is because files are not there anymore and url cache still have this paths for urls. This should be resolved by library itself, cause it makes other problems too. Check PR #91 , library should check if file exists under path returned by url cache before returns it to Image component.

kfiroo commented 6 years ago

@chrusart Clearing the cache should clear both url cache and local image files. https://github.com/kfiroo/react-native-cached-image/blob/1c0a9c412d08014e8083c8f3b5cc2924e469593b/ImageCacheManager.js#L124-L128

I think the problem is that the CachedImage doesn't refresh when the cache is cleared, it's data didn't change and so it still displays the old image from memory

ruoyuruoshui commented 6 years ago

@kfiroo if the state of CachedImage state(cachedImagePath, isCacheable) is not reset, image will not be refreshed. i tried to add a listener on clearCache to reset state, it works. but i think this solution is too low, do you has any solution on this?

kfiroo commented 6 years ago

@ruoyuruoshui I Completely understand the need but I can't think of anything right now :( Suggestions are welcome..

chrusart commented 6 years ago

Could you check current version, at least 1.4.2?