import React from 'react'; import PropTypes from 'prop-types'; import { TouchableOpacity, ActivityIndicator } from 'react-native'; import FastImage from 'react-native-fast-image'; import styles from './styles'; import { CustomIcon } from '../../lib/Icons'; import { COLOR_PRIMARY } from '../../constants/colors'; export default class CommandPreview extends React.PureComponent { static propTypes = { onPress: PropTypes.func, item: PropTypes.object }; constructor(props) { super(props); this.state = { loading: true }; } render() { const { onPress, item } = this.props; const { loading } = this.state; return ( onPress(item)} testID={`command-preview-item${ item.id }`} > {item.type === 'image' ? ( this.setState({ loading: true })} onLoad={() => this.setState({ loading: false })} > { loading ? : null } ) : } ); } }