Summary
Controlled components are React's recommended method for handling form data entry. With controlled components, React controls the field component values via the component state.
Implementing many forms that contain lots of fields involves writing lots of repetitive boilerplate code for the field value state and change event handlers. Implementing generic form and field components that do the state management can significantly reduce the amount of code needed to implement a form. The generic form and field components can encapsulate validation and form submission as well.
Our generic components only deal with very simple forms. For example, what if our next form required a drop-down menu or a date picker? What if a validator function ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access