Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native Image how to use onError

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.

like image 989
tjkind Avatar asked Oct 24 '25 23:10

tjkind


1 Answers

This 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.

like image 89
Prasun Avatar answered Oct 27 '25 12:10

Prasun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!