javascript - React textarea onChange改写内部state

react-mmp

2018-03-02T03:59:18Z||2018-03-02T03:59:18Z

代码:

class EssayForm extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      value: 'Please write an essay about your favorite DOM element.'
    };
  }

  render() {
    return (
      <form onSubmit={this.handleSubmit}>
        <label>
          Essay:
          <textarea value={this.state.value} onChange={(event) => this.setState({value: event.target.value})} />
        </label>
      </form>
    );
  }
}