1import * as React from 'react'; 2import { StyleSheet, View, ViewStyle } from 'react-native'; 3 4import { defaultImage } from './images'; 5import { ImageTestComponent, ImageTestProps } from './types'; 6 7type PropsType = { 8 style?: ViewStyle; 9 imageProps: ImageTestProps; 10 ImageComponent: ImageTestComponent; 11 loadOnDemand?: boolean; 12}; 13 14export default class ImageTestView extends React.PureComponent<PropsType> { 15 render() { 16 const { imageProps, ImageComponent, loadOnDemand } = this.props; 17 const { style, source, ...otherImageProps } = imageProps; 18 return ( 19 <View style={styles.container}> 20 <ImageComponent 21 style={[styles.image, this.props.style, style]} 22 source={source && !loadOnDemand ? source : defaultImage} 23 {...otherImageProps} 24 /> 25 </View> 26 ); 27 } 28} 29 30const styles = StyleSheet.create({ 31 container: { 32 flex: 1, 33 justifyContent: 'center', 34 alignItems: 'center', 35 backgroundColor: 'white', 36 }, 37 image: { 38 width: 200, 39 height: 200, 40 }, 41}); 42