Skip to content

Instantly share code, notes, and snippets.

@1fabiopereira
Created July 12, 2017 12:51
Show Gist options
  • Save 1fabiopereira/d3bc499ef1b6396672fbeae1a65b3820 to your computer and use it in GitHub Desktop.
Save 1fabiopereira/d3bc499ef1b6396672fbeae1a65b3820 to your computer and use it in GitHub Desktop.
react-native simple custom button
import React from "react";
import {Text, TouchableOpacity, View} from "react-native";
import PropTypes from "prop-types";
import Styles from "./_styles";
const Button = (props) => {
return (
<View style={ Styles.btn }>
<TouchableOpacity
style={
[
{
backgroundColor: props.color,
borderColor: props.borderColor,
},
Styles.btnTemplate,
props.style,
]
}
onPress={ () => props.handler() }>
<Text style={ {color: props.textColor} }>
{props.text}
</Text>
</TouchableOpacity>
</View>)
};
Button.propTypes = {
borderColor: PropTypes.string.isRequired,
color: PropTypes.string.isRequired,
handler: PropTypes.func.isRequired,
style: PropTypes.object,
text: PropTypes.string.isRequired,
textColor: PropTypes.string.isRequired,
};
export default Button;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment