Created
December 15, 2018 23:56
-
-
Save sekcompsci/084de03bc1ea19bbb5240271d364bf01 to your computer and use it in GitHub Desktop.
Create React Native App - First App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { StyleSheet, Text, View, Button, Alert } from 'react-native'; | |
export default class App extends React.Component { | |
showAlert = () => { | |
Alert.alert( | |
'Alert Title', | |
'My Alert Msg', | |
[ | |
{text: 'Ask me later', onPress: () => console.log('Ask me later pressed')}, | |
{text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'}, | |
{text: 'OK', onPress: () => console.log('OK Pressed')}, | |
], | |
{ cancelable: false } | |
) | |
}; | |
render() { | |
return ( | |
<View style={styles.container}> | |
<Text>Hello World!</Text> | |
<Button | |
onPress={this.showAlert} | |
title="Learn More" | |
color="#841584" | |
accessibilityLabel="Learn more about this purple button" | |
/> | |
</View> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
backgroundColor: '#fff', | |
alignItems: 'center', | |
justifyContent: 'center', | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment