From the course: Build Modern Web Apps with React, Hooks, State Management, and APIs Using Vite or Next.js

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Signup form state and submission

Signup form state and submission

Welcome back, let's get started with our signup form. We are going to go in VS Code. And in the components folder, we are going to create a new file. We will call it signupform.tsx. We are going to run rafce. And this will give us our signup form. So the first thing over here is that we are going to need a state. So let's declare our state variable. We will be having a loading state of type boolean and it will be having a setter function. We can declare a state of Boolean type and we can pass on value false. We are going to use this value whenever we are making API calls, then we set this value to true and once the data has been fetched, then this can be set to false again. And whenever this value is going to be true, we will be showing some loading state or message notifying the user that data is currently loading. After that, we are going to import our use form from react-hook form. So let's do that. As you know, we need this hook to actually settle down our state. Now from this…

Contents