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)
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 atthis.state.path, so the built inImagecomponent is throwing this warning when it can’t loadundefined.png. I have to think it’s just becauseRNFetchBlob.fs.exists()is a Promise and it’s delaying anything until the next loop, which is going to miss that firstrender()call?For what it’s worth, I don’t think the
styleprop 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.pathso 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,
*.pngisn’t specified in my code. The ajax data gets.jpgfiles. I have a couple local.pngfiles that I was running thruCachedImage, but it wasn’t working so now I run them thruImage. 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 useCachedImageit warns about an error case from the past and doesn’t forget.