React - TextArea

In React, a uses a value attribute instead. This way, a form using a can be written very similarly to a React form that uses a single-line input. See React - Input Element
Example Controlled Component
Example of a form implemented as a controlled component written in a class syntax
class EssayForm extends React.Component {
  constructor(props) {
    this.state = {
      value: 'Please write an essay about your favorite DOM element.'

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

  handleChange(event) {

  handleSubmit(event) {
    console.log('An essay was submitted: ' + this.state.value);

  render() {
    return (
      <form onSubmit={this.handleSubmit}>
          <textarea cols="50" rows="3" value={this.state.value} onChange={this.handleChange} />
        <input type="submit" value="Submit" />

  <EssayForm />,
<div id="root"></div>

Discover More
React - Form

HTML form elements work a little bit differently from other DOM elements in React, because form elements naturally keep some internal state. : The state is controlled by React : The state is controlled...

Share this page:
Follow us:
Task Runner