Working with Forms
Forms are extremely common in apps, so it’s essential to be able to efficiently implement them. In some apps, forms can be large and complex, and getting them to perform well is challenging.
In this chapter, we’ll learn how to build forms in React using different approaches. The example form we will make here is a contact form that you would often see on company websites. It will contain a handful of fields and some validation logic.
The first approach to building a form will be to store field values in the state. We will see how this approach can bloat code and hurt performance. The next approach embraces the browser’s native form capabilities, reducing the amount of code required and improving performance. We will then use React Router’s Form
component, which we briefly covered in Chapter 6, Routing with React Router. The final approach will be to use a popular library called React Hook Form. We’ll experience how React Hook...