Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dantejauregui/0191ae6fe4d0c986d90a348efc22d754 to your computer and use it in GitHub Desktop.
Save dantejauregui/0191ae6fe4d0c986d90a348efc22d754 to your computer and use it in GitHub Desktop.
duda react onchange
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
texto: '',
saludo: '',
cambio: ''
};
this.show = this.show.bind(this);
this.changing = this.changing.bind(this);
}
show(){
this.setState({ saludo: `Hola ${this.state.texto}`});
}
changing(e){
this.setState({
texto: e.target.value
})
}
render() {
return (
<View style={styles.container}>
<TextInput
style={{height: 40, width:100, borderColor: 'gray', borderWidth: 1, textAlign: 'center', marginBottom: 20}}
value={this.state.texto}
onChangeText={this.changing}
/>
<Button title="Hola" color="#2f2f2f" onPress={this.show}/>
<Text style={styles.paragraph}>
{this.state.saludo.toUpperCase()}
</Text>
</View>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment