Add fallback option.
This commit is contained in:
parent
400232767b
commit
30a2ff7909
20
src/index.js
20
src/index.js
|
@ -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, {
|
||||
|
|
Loading…
Reference in New Issue