Hi I'm currently trying to load several network images and they often fail to load on android. I'm trying to use onError to diagnose why but can't seem to get it to work.
I've tried using it as
onError={(e) => console.log(e}
and
onError(error){
console.log(error)
}
onError={ this.onError.bind(this) }
but both of these result in this object
Proxy [[Handler]]: Object [[Target]]: SyntheticEvent [[IsRevoked]]: false
which, as best as I can tell, is the error event and doesn't contain anything useful.
My question is how do I use onError to diagnose why my network images are failing? but if you have any ideas about why I'll gladly take those too.
Hi I'm currently trying to load several network images and they often fail to load on android. I'm trying to use onError to diagnose why but can't seem to get it to work.
I've tried using it as
onError={(e) => console.log(e}
and
onError(error){
console.log(error)
}
onError={ this.onError.bind(this) }
but both of these result in this object
Proxy [[Handler]]: Object [[Target]]: SyntheticEvent [[IsRevoked]]: false
which, as best as I can tell, is the error event and doesn't contain anything useful.
My question is how do I use onError to diagnose why my network images are failing? but if you have any ideas about why I'll gladly take those too.
Share Improve this question asked Mar 6, 2018 at 17:28 tjkindtjkind 1711 gold badge1 silver badge7 bronze badges2 Answers
Reset to default 15This is an SyntheticEvent, as specified in the Image doc here, you can try following code
onError=({ nativeEvent: {error} }) => console.log(error)
Hope this will help.
try this
<Image
onError={(error) => {
const getCircularReplacer = () => {
const seen = new WeakSet();
return (key, value) => {
if (typeof value === "object" && value !== null) {
if (seen.has(value)) {
return;
}
seen.add(value);
}
return value;
};
};
console.log("this Images Error ")
console.log(JSON.stringify(error, getCircularReplacer()))
}
}
/>