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.

Watch useForm

Watch useForm

Hello and welcome back. In this video, we'll discuss about how we can watch the input values. Watching can be useful when we have a real-time validation or we want to do some conditional rendering based on the value of an input. And lastly, if we want to debug that what certain values and field of the form has gotten. This is the syntax, a watch value, if defined, it can get reactively updated and we get to see whatever value over the time over the course of the re-rendering we are getting inside. Let's understand that by an example. I am going to do a few examples which is going to give you an idea of the conditional rendering, real-time validations or debugging. In this form example, we are going to define a variable, let's say name value and we are going to use the watch function. closely that since the use form is defined based on the form data type, then you can only get to watch on the specific fields that are defined in your type. Let's say we watch on the name field. And for…

Contents