Thinking in ReactJS way:
import React, {Component} from 'react'; export default MyApp extends Component { constructor(props){ super(props); //Creates a value in state. this.state = {myValue: ''}; }
//Creates a function to effectively changes the value inside your state.
handleChange(event){
this.setState({myValue: event.target.value});
}
render() {
//two way binding:
//value={this.state.myValue}
//onChange={this.handleChange}
//Receives the value set in your state, and when you change it, inform to change inside the state as well.
return(
<input type="text" value={this.state.myValue} onChange={this.handleChange} />
);
}
}
Holpe helped. =D