react-native-img-cache: Could not find image named undefined.png

Getting many of these warnings. Images still show though. Don’t get this with Image.

Could not find image named undefined.png

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

Yeah I’m seeing this issue as well and I think it’s because of this line: https://github.com/wcandillon/react-native-img-cache/blob/master/src/index.tsx#L101

I actually see render() getting called twice before the component finally has a value at this.state.path, so the built in Image component is throwing this warning when it can’t load undefined.png. I have to think it’s just because RNFetchBlob.fs.exists() is a Promise and it’s delaying anything until the next loop, which is going to miss that first render() call?

For what it’s worth, I don’t think the style prop has anything to do with this issue as mentioned above. All that does is allow RN to determine it doesn’t even need to attempt to load the image because it has no dimensions and won’t be displayed anyways, so the warning is never thrown.

I’m not exactly sure what the right solution is here, but one idea is to allow for passing a placeholder image path that could be set as the initial value of this.state.path so that something is displayed while it pulls the image from cache or downloads the image.

For those who are affected by the warning, you can disable that specific yellow box warning with console.ignoredYellowBox = ['Could not find image'] somewhere near the entry point of your app. This will prevent the yellow box from being displayed, but you’ll still see the warnings in your debugging console.

@kirkstrobeck I ran a couple of tests on IOS and couldn’t reproduce the issue. Is it possible that you experienced the issue on android? Please feel free to re-open if this is the case of if you have more information on how to reproduce the issue.

No, *.png isn’t specified in my code. The ajax data gets .jpg files. I have a couple local .png files that I was running thru CachedImage, but it wasn’t working so now I run them thru Image. Perhaps uninstalling the app would blow away the cache? but that image isn’t referenced any longer so not sure whats causing this? Looks like the pattern is that whenever I use CachedImage it warns about an error case from the past and doesn’t forget.