ReactJS Forms Basics

HTML form elements work a little bit differently from other DOM elements in React, because form elements naturally keep some internal state. For example, this form in plain HTML accepts a single name:

<form>

<label>

Name:

<input type=”text” name=”name” />

</label>

<input type=”submit” value=”Submit” />

</form>

This form has the default HTML form behavior of browsing to a new page when the user submits the form. If you want this behavior in React, it just works. But in most cases, it’s convenient to have a JavaScript function that handles the submission of the form and has access to the data that the user entered into the form. The standard way to achieve this is with a technique called “controlled components”.

Share this post
[social_warfare]
ReactJS Forms
Controlled Components

Get industry recognized certification – Contact us

keyboard_arrow_up