Controlled Components vs. Uncontrolled Components

Learn about controlled and uncontrolled components in React forms.

Controlled components

When we create forms with Formik, we create a state that stores the form’s data. This means that the value of each field is always deduced from this state, and mutations are controlled by event handlers that communicate with this state.

In React, this is what we call controlled components because everything about the form is controlled by a central state. This state serves as the single source of truth for all the fields in the form.

Beyond working with Formik, we can also create controlled components by creating a state in the component that stores the form’s data. In React, we use the useState hook to create a state.

Get hands-on with 1200+ tech skills courses.