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.

Controlled vs uncontrolled: In depth

Controlled vs uncontrolled: In depth

Hello and welcome to lesson number 2. In this lesson, we will understand the controlled versus uncontrolled components in depth. So right now, we know that what are controlled components. To revise that, any component that you are dealing with is having a form and the form inputs are controlled by react's useState, then you are dealing with a controlled component. The key points as we know that the input value is going to be stored inside react state by using the useState hook. Every keystroke updates the value of the state. Right now we are dealing with an onChange event and whatever the value that is being entered inside any form or any of the input element is being updated to the state using the setter function of the useState. Control components are great for validation or conditional UI elements. For example, on the basis of user selected value, you want to show certain piece of the UI or you want to hide a certain piece of the UI, then using the control components is a great…

Contents