This style is what I see on tutorials everywhere
onChangeText = { (e)=>{this.setState({input:e})} }
Another style without lambda expressions
changeText: function(text) {
this.setState({input: text});
},
render: function() {
return (
<React.TextInput onChangeText={ this.changeText } />
);
}
However this doesn't.
render: function() {
return (
<React.TextInput onChangeText = { function(text) {this.setState({input: text});} }/>
);
}
- For code block 2, where does this.changeText get the input text from?
- For code block 3, why can't I declare the function inline?
I'm not sure what's the proper terms to look this up, so I appreciate if anybody can point me in the direction