Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react input text onchange target method

class App extends React.Component {
  constructor(props) {
    super(props);
    
    this.state = {
      data: 'Bound data...'
    }
    this.updateState = this.updateState.bind(this);
    
  };
  updateState(e) {
    this.setState({data: e.target.value});
  }
  render() {
    return (
    <>
        <input type="text" value = {this.state.data} onChange = {this.updateState} />
        <h4>{this.state.data}</h4>
        </>
             );
  }
}
        ReactDOM.render(
        <App />, document.getElementById('mountNode') );
Source by jscomplete.com #
 
PREVIOUS NEXT
Tagged: #react #input #text #onchange #target #method
ADD COMMENT
Topic
Name
7+3 =