React-Form-Control Flashcards

1
Q

How do controlled components differ from uncontrolled components?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are some advantages of using uncontrolled components?

A

components don’t have to re-render

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are some advantages of using controlled components?

A

The UI and the data are in sync
Form component can respond to input changes immediately

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which style do you prefer?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What two props must you pass to an input for it to be “controlled”?

A

A value prop for text inputs and a onChange event prop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are some popular npm packages for creating forms in React?

A

React Hook Form, Formik, and React Final Form.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly