react-native-cached-image icon indicating copy to clipboard operation
react-native-cached-image copied to clipboard

Changes in v1.4 vs v1.3

Open jose920405 opened this issue 8 years ago • 9 comments

Hi, Thanks for this module it has been very helpful.

In v1.3 version i was using a lot getCachedImagePath and cacheMultipleImages.

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.

jose920405 avatar Oct 19 '17 17:10 jose920405

ImageCachePreloader.preloadImages, don't konw about getCachedImagePath replacement

chrusart avatar Oct 19 '17 19:10 chrusart

@jose920405 What were you using getCachedImagePath for?

kfiroo avatar Oct 20 '17 14:10 kfiroo

i'm using getCachedImagePath for offline logic, converting the images in that patch to base64 and load to a canvas

jose920405 avatar Oct 20 '17 15:10 jose920405

When you are offline and the image is already cached, CachedImage will load and display it, why are you doing this manually?

kfiroo avatar Oct 20 '17 15:10 kfiroo

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 avatar Oct 20 '17 15:10 jose920405

@jose920405 I got it! Thanks! So you should use ImageCacheManager.downloadAndCacheUrl This method will return the path to the local file.

kfiroo avatar Oct 20 '17 21:10 kfiroo

@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?

mik-rom avatar Nov 02 '17 14:11 mik-rom

@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(...)

esamelson avatar Nov 07 '17 18:11 esamelson

cacheMultipleImages now is?

jose920405 avatar Jan 03 '18 12:01 jose920405