Standard HTML form elements and React DOM elements work a bit differently.
How forms are handled in HTML and React?
HTML form elements maintain their own state and update the state based on the user inputs.
In React, it’s a bit different. React keeps a mutable state of components and it gets updated using setState().
How to create a controlled component?
Creating controlled component requires you to combine both HTML and React handling of form elements and making the React state as the controller. So, the same React component that renders the form elements has now more control over those elements and it can control what happens inside those form elements.
A Controlled Component is nothing but a technique of controlling the value of form input elements by Recat.
React simple form example
As you can see in the example above, we are setting the value of input element as this.state.value and the state of the input element will keep changing on user input. Hence, we can have access to the current value way before user submits the value.
The handleChange will keep the React state updated. You can actually type something and see the console logging the most recent value every single time.