React-Form-Control Flashcards
How do controlled components differ from uncontrolled components?
For controlled elements, React takes control of the form data and maintains the state of the form element. The component decides when and how to update the state, and it re-renders itself based on the state changes.
For uncontrolled elements, a form element in a component is controlled by the DOM. The DOM decides the state of the input element and updates it based on a user’s input.
What are some advantages of using uncontrolled components?
components don’t have to re-render
What are some advantages of using controlled components?
The UI and the data are in sync
Form component can respond to input changes immediately
Which style do you prefer?
What two props must you pass to an input for it to be “controlled”?
A value prop for text inputs and a onChange event prop
What are some popular npm packages for creating forms in React?
React Hook Form, Formik, and React Final Form.