Skip to content

Instantly share code, notes, and snippets.

@AllGistsEqual
Last active May 1, 2020 20:02
Show Gist options
  • Save AllGistsEqual/aaa712f548b0f949f64a413ae1c227c5 to your computer and use it in GitHub Desktop.
Save AllGistsEqual/aaa712f548b0f949f64a413ae1c227c5 to your computer and use it in GitHub Desktop.
import React from 'react'
import PropTypes from 'prop-types'
import {
StyleSheet,
Text,
View,
TouchableOpacity,
} from 'react-native'
const IconButton = ({
icon,
size,
customStyles,
onPress,
}) => (
<TouchableOpacity
style={customStyles}
onPress={() => onPress()}
>
<View style={styles.button}>
<Text style={{ ...styles.icon, fontSize: size }}>
{icon}
</Text>
</View>
</TouchableOpacity>
)
const styles = StyleSheet.create({
button: {
overflow: 'hidden',
},
icon: {
textAlign: 'center',
},
})
IconButton.defaultProps = {
size: 18,
customStyles: {},
onPress: undefined,
}
IconButton.propTypes = {
icon: PropTypes.string.isRequired,
size: PropTypes.number,
customStyles: PropTypes.object,
onPress: PropTypes.func,
}
export default IconButton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment