jayesbe / react-native-cacheable-image

An Image Component for React Native that will cache itself to disk.
MIT License
304 stars 78 forks source link

Not refreshing when URL changes #49

Open techrah opened 7 years ago

techrah commented 7 years ago

I have a CacheableImage component in my view. When the URL changes (via a redux reducer), the image is not getting updated. I've confirmed that the view itself is getting re-rendered with the new URL. If I replace CacheableImage with Image, it works as expected.

I checked the code and see that you are handling the source change via componentWillReceiveProps so I'm confused as to why it's not working. Any thoughts or suggestions?

Crash-- commented 7 years ago

Does your image is rendered inside a ListView ? If yes, take a look at this issue https://github.com/facebook/react-native/issues/1417

eneskaya commented 7 years ago

@ryanhomer I experienced the same issue and after adding a key prop with the image URI it worked.

techrah commented 7 years ago

@Crash-- @eneskaya Thanks for the responses. I ended up using react-native-cached-image instead which fixed the issue for me but I was not using the key property so, good to know.

mekoahdd commented 7 years ago

The solution of the key worked for me

< CacheableImage source={{uri:object.image}} key={object.image_key} / >