Created
August 15, 2018 18:24
-
-
Save adrian-afergon/64cac9b1a2ecffec4ebf3df7fe6983cd to your computer and use it in GitHub Desktop.
Event click change view
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 } from 'react-native'; | |
export default class App extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = {text: 'Hello World'}; | |
} | |
render() { | |
return ( | |
<View style={styles.container}> | |
<Text>{this.state.text}</Text> | |
<Button title='This is my button' onPress={this.handlerPress}/> | |
</View> | |
); | |
} | |
handlerPress = () => { | |
this.setState({text: 'Button has been clicked'}); | |
} | |
} | |
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