Summary
In this chapter, we learned that forms can be implemented using controlled components in React. With controlled components, React controls the field component values via state, and we are required to implement boilerplate code to manage this state.
React Hook Form is a popular forms library in the React community. This removes the need for boilerplate code, which you need with controlled components.
We now understand that the register
function can be set to a React element's ref
property to allow React Hook Form to manage that element. Validation rules can be specified within the register
function parameter.
We can pass form submission logic into the handleSubmit
function from React Hook Form. We learned that isSubmitting
is a useful flag within formState
that we can use to disable a form while submission is taking place.
In the next chapter, we are going to focus heavily on state management in our app and leverage Redux.