Introduction to Formik

Learn how Formik makes it easier to create React forms.

Issues with creating forms in React

Let’s explore some of the problems that can arise during the various stages of form development in React, particularly when dealing with larger forms.

Managing the form state

When creating a React form the traditional way, we need to set up states to keep track of the values and errors in each of our form fields. We also need to keep track of the touched state so we know the input fields that have been visited.

As the form gets bigger, we have more fields, and this increases the size of our state. This is because for each field we’re tracking, at least three states—the value of the field, the touched state, and the error state. All of these states make the form more difficult to manage.

Validating form values

We used multiple if statements to test for different possible validation constraints of each field. More fields in our form ...