Created
May 19, 2017 02:07
-
-
Save dantejauregui/0191ae6fe4d0c986d90a348efc22d754 to your computer and use it in GitHub Desktop.
duda react onchange
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
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