vivaxy / react-native-auto-height-image

🖼️React native auto height image

Home Page:https://github.com/vivaxy/react-native-auto-height-image

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Event Success

jvitorr opened this issue · comments

Hello,

There is a event when Image is loaded ?

@jvitorr You can use onLoad, onLoadStart and onLoadEnd event handler.
The results of those events are handled by react-native Image. react-native-auto-height-image loads image at the mean time using Image.getSize api. Image.getSize result only affects onError event handler.
If you have further more questions, feel free to ask here.

@vivaxy still not clear though how one can achieve if image is loaded or not? Any help or snipet will be appreciated.

@mak12 just set onLoadEnd and onError props on your react-native-auto-height-image component. Any extra props get passed down to the underyling React Native Image:

https://github.com/vivaxy/react-native-auto-height-image/blob/master/autoHeightImage.js#L92

It would look something like:

<AutoHeightImage
  width={100}
  source={{uri: 'https://vivaxy.github.io/404'}}
  fallbackSource={image}
  onLoad={() => { console.log("it loaded! :D"); }}
  onError={() => { console.error("it didn't load! (ノಠ益ಠ)ノ彡┻━┻"); }} />