Skip to content

Instantly share code, notes, and snippets.

@topspinppy
Created August 21, 2019 15:25
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 topspinppy/9bb02144b988cde01d1f54f34e83dec7 to your computer and use it in GitHub Desktop.
Save topspinppy/9bb02144b988cde01d1f54f34e83dec7 to your computer and use it in GitHub Desktop.
getting started React Native
import React, { useState } from 'react';
import { StyleSheet, Text, View, TextInput, Button, Alert } from 'react-native';
export default function App() {
const [ text, setText ] = useState("This is our message on Screen");
const [ todo, setTodo ] = useState("");
addTodo = () => {
setTodo(text);
Alert.alert('Alert Box', "Oops you Touch Me!");
}
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your !</Text>
<TextInput
style={styles.inputStyle}
onChangeText={(text) => setText(text)}
/>
<Button
title="Add Todo"
onPress={this.addTodo}
/>
<Text>{todo}</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#ffffff',
alignItems: 'center',
justifyContent: 'center',
},
inputStyle: {
height: 40,
borderColor: "green",
borderWidth: 1,
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment