Validating a Login Form With React
For almost every form that you create, you will want some sort of validation. In React, working with and validating forms can be a bit verbose, so in this article we are going to use a package called Formik to help us out!
TLDR
Create a React project
Add the Formik (and Yup) packages
Customize the Formik component with an onSubmit callback and a validate function for error messages
then display those error messages to the user.> View the final code on CodeSandbox!
Here's a sneak peak at what we are going to create.
https://codesandbox.io/s/4203r4582w
Creating the React Project
For this demo, I'll be using CodeSandbox. You can use CodeSandbox as well or use your local environment. Totally up to you.
Regardless of what you use for this demo, you need to start with a new React ...