Closed n1xn closed 5 years ago
After hours of migrating from this lib to fast-image, I can say this lib made my android version very slow.
"this lib made my android version very slow." ? which library you referring react-native-fast-image or react-native-cached-image ?
This lib, drastically slows down the performance on Android.
I have experienced very good performance with React-Native-Fast-Image because it wraps Glide on Android and SDWebImage on iOS.
but there is no facility to clear cache with React-Native-Fast-Image https://github.com/DylanVann/react-native-fast-image/issues/267
For me its performance over Cache control.
But you can implement it yourself, the native libs wraped around this do support clearing cache. So it’s up to you..
After I changed the profileImgUrl I saw that the lib is caching but always downloads the image again. I can see this because I turned airplane-mode on, on my device. Now no image will be shown. I checked by console.log(imgManager.getCacheInfo()) if the images are cached, they are. I tried it in 2 different ways. 1 ist not using the provider at all, the second is using one
No Prodiver used:
<CachedImage style={styles.profileImage} source={ this.state.user_profileImgUrl ? this.state.user_profileImgUrl : "" } fallbackSource={require("../../../assets/icons/default_profile_image.png")} />
Provider used:
<ImageCacheProvider> <CachedImage style={styles.profileImage} source={ this.state.user_profileImgUrl ? this.state.user_profileImgUrl : "" } defaultSource={ "myUrl" } /> </ImageCacheProvider>
And this is how I am using to get the URL:
imgManager .downloadAndCacheUrl(userData.profileImgUrl) .then(imagePath => { if (Platform.OS === "android") { imagePath = "file://" + imagePath; } this.setState({ user_profileImgUrl: imagePath }); }) .catch(() => { });