How to get value of textbox in React?

As described in documentation You need to use controlled input. To make an input – controlled you need to specify two props on it

  1. onChange – function that would set component state to an input value every time input is changed
  2. value – input value from the component state (this.state.value in example)

Example:

  getInitialState: function() {
    return {value: 'Hello!'};
  },
  handleChange: function(event) {
    this.setState({value: event.target.value});
  },
  render: function() {
    return (
      <input
        type="text"
        value={this.state.value}
        onChange={this.handleChange}
      />
    );
  }

More specifically about textarea – here

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)