Skip to content

Instantly share code, notes, and snippets.

@sekcompsci
Created December 15, 2018 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sekcompsci/084de03bc1ea19bbb5240271d364bf01 to your computer and use it in GitHub Desktop.
Save sekcompsci/084de03bc1ea19bbb5240271d364bf01 to your computer and use it in GitHub Desktop.
Create React Native App - First App
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