Skip to content

Instantly share code, notes, and snippets.

@Hychhayrith
Created August 23, 2019 05:59
Show Gist options
  • Save Hychhayrith/70b1367803864a5c6eb93097d49947e2 to your computer and use it in GitHub Desktop.
Save Hychhayrith/70b1367803864a5c6eb93097d49947e2 to your computer and use it in GitHub Desktop.
import React, {Component} from 'react';
import { StyleSheet, Text, View, Alert, TouchableHighlight } from 'react-native';
export default class TouchableButton extends Component {
_onPress() {
Alert.alert("The button is pressed");
}
// Note: Long press is available for Touchable Button
_onLongPress() {
Alert.alert("Long pressed the button");
}
render() {
return (
<TouchableHighlight
underlayColor="white"
onPress={this._onPress}
onLongPress={this._onLongPress}
>
<View style={styles.button}>
<Text style={styles.buttonText}>Touchable Button</Text>
</View>
</TouchableHighlight>
)
}
}
const styles = StyleSheet.create({
button: {
marginBottom: 0,
alignItems: 'center',
backgroundColor: '#2196F3'
},
buttonText: {
paddingLeft: 20,
paddingRight: 20,
color: 'white'
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment