Submitting the form is the final part of the form implementation that we'll do in this section. The consumer of the Form component will handle the actual submission. Our Form component will revalidate the form and call a function in the consumer code when the form is submitted.
Submitting forms
Handling form submission
We already have a submit button in the Form component that submits the form. We aren't handling the form submission yet though. Let's handle form submission, which includes a call to a function passed in by the consumer:
- In Form.tsx, let's import the FormEvent type from React:
import { FC, useState, createContext, FormEvent } from 'react';
- Let's add an event listener for...