Skip to content

Instantly share code, notes, and snippets.

@adrian-afergon
Created August 15, 2018 18:24
Show Gist options
  • Save adrian-afergon/64cac9b1a2ecffec4ebf3df7fe6983cd to your computer and use it in GitHub Desktop.
Save adrian-afergon/64cac9b1a2ecffec4ebf3df7fe6983cd to your computer and use it in GitHub Desktop.
Event click change view
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