All:
I am pretty new to React, when I try to make a very simple component like a inputbox with a label, which the label can change according to the input of input box.
class App extends React.Component {
constructor() {
super();
this.name = "World";
}
changeName(e){
var nameinput = this.refs.nameinput;
this.name = nameinput.value;
}
render(){
return (
<div>
<input ref="nameinput" onChange={this.changeName} />
Hello, {this.name}!
</div>
);
}
}
Currently the problem is in changeName() function, there is no reference to App( when I print out this
, it is undefined) I wonder how can I get the reference to that inputbox with something like refs.nameinput.value
Thanks