import React from 'react'; import PropTypes from 'prop-types'; import { View, Text, TouchableWithoutFeedback, Image } from 'react-native'; import styles from './styles'; export default class Button extends React.PureComponent { static propTypes = { title: PropTypes.string, subtitle: PropTypes.string, type: PropTypes.string, icon: PropTypes.node.isRequired, testID: PropTypes.string.isRequired, onPress: PropTypes.func } static defaultProps = { title: 'Press me!', type: 'primary', onPress: () => alert('It works!') } state = { active: false }; render() { const { title, subtitle, type, onPress, icon, testID } = this.props; const { active } = this.state; const activeStyle = active && styles.buttonActive; return ( this.setState({ active: true })} onPressOut={() => this.setState({ active: false })} testID={testID} > {icon} {title} {subtitle ? {subtitle} : null} {type === 'secondary' ? : null} ); } }