Created
August 21, 2019 15:25
-
-
Save topspinppy/9bb02144b988cde01d1f54f34e83dec7 to your computer and use it in GitHub Desktop.
getting started React Native
This file contains 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, { 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