Open jose920405 opened 6 years ago
ImageCachePreloader.preloadImages, don't konw about getCachedImagePath replacement
@jose920405 What were you using getCachedImagePath
for?
i'm using getCachedImagePath
for offline logic, converting the images in that patch to base64 and load to a canvas
When you are offline and the image is already cached, CachedImage
will load and display it, why are you doing this manually?
But i'm not loading a image inside render
in a react component. I'm try to render the image inside a CANVAS
. And in my canvas i'm receiving base64
image data. That is the reason for use getCachedImagePath
and convert the image to base64
@jose920405 I got it! Thanks!
So you should use ImageCacheManager.downloadAndCacheUrl
This method will return the path to the local file.
@kfiroo I'm getting undefined is not a function when trying to use this function
import { CachedImage, ImageCacheManager } from 'react-native-cached-image'
ImageCacheManager.downloadAndCacheUrl(this.props.source.uri)
.then((imagePath) => {
if(Platform.OS === 'android') {
imagePath = 'file://' + imagePath
}
this.setState({renderAnimated: false, imagePath: imagePath})
})
.catch(() => {
this.setState({renderAnimated: true})
})
TypeError: _reactNativeCachedImage.ImageCacheManager.downloadAndCacheUrl is not a function
Before this update I used ImageCacheProvider.getCachedImagePath and it worked without an error.
Any ideas?
@rom1k I just ran into the same issue. It looks like there was another change in 1.4 that was not documented - ImageCacheManager seems to be a factory. This worked for me:
import { ImageCacheManager } from 'react-native-cached-image'
const manager = ImageCacheManager({})
manager.downloadAndCacheUrl(...)
cacheMultipleImages
now is?
Hi, Thanks for this module it has been very helpful.
In
v1.3
version i was using a lotgetCachedImagePath
andcacheMultipleImages
.When updating to the new version v1.4 I found that in the readme these options do not exist anymore. What would be the equivalences for these functions? I wish I did not have to make many changes in my logic on this.