Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

React - Forms element of textarea tag

0 votes
10 views
added Nov 8 in React by LC Marshal Captain (25,420 points)
class LandyForm extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      value: 'Write your word about land rover'
    };

    this.handleChange = this.handleChange.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
  }

  handleChange(event) {
    this.setState({value: event.target.value});
  }

  handleSubmit(event) {
    alert('Word being submitted: ' + this.state.value);
    event.preventDefault();
  }

  render() {
    return (
      <form onSubmit={this.handleSubmit}>
        <label>
          Essay:
          <textarea value={this.state.value} onChange={this.handleChange} />
        </label>
        <input type="submit" value="Submit" />
      </form>
    );
  }
}

 

Please log in or register to response this reference.

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...