Add fallback option.

This commit is contained in:
Dylan Vann 2018-06-13 20:34:30 -04:00
parent 400232767b
commit 30a2ff7909
1 changed files with 20 additions and 0 deletions

View File

@ -31,11 +31,30 @@ class FastImage extends Component {
onLoadEnd,
style,
children,
fallback,
...props
} = this.props
const resolvedSource = resolveAssetSource(source)
if (fallback) {
return (
<View style={[style, styles.imageContainer]} ref={this.captureRef}>
<FastImageView
{...props}
style={StyleSheet.absoluteFill}
source={resolvedSource}
onLoadStart={onLoadStart}
onProgress={onProgress}
onLoad={onLoad}
onError={onError}
onLoadEnd={onLoadEnd}
/>
{children}
</View>
)
}
return (
<View style={[style, styles.imageContainer]} ref={this.captureRef}>
<FastImageView
@ -95,6 +114,7 @@ FastImage.propTypes = {
onLoad: PropTypes.func,
onError: PropTypes.func,
onLoadEnd: PropTypes.func,
fallback: PropTypes.bool,
}
const FastImageView = requireNativeComponent('FastImageView', FastImage, {