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.

Pros and cons of each approach

Pros and cons of each approach

Hello and welcome back, in this video we'll understand the pros and cons of using controlled and uncontrolled components. Let's discuss the controlled component pros and cons first. Controlled components are great for dynamic forms and forms with validations. Often at times, you have to put in user validations that is having controlled form of data. You cannot allow user to just enter anything in the open text boxes or text areas. Or on the basis of user selection value, you might have to perform some of the validation. For example, if user's age is greater than 18, only then you should be allowing them to continue forward. Control components are easy to debug. You have the state control values, you can use the react development tools or you can log a value to see how things are shaping up inside your component and you can easily debug what the issue is. A bit of cons of using control components include that there are more of a boilerplate code. You have to use kind of similar…

Contents