From the course: React: Design Patterns

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Controlled vs. uncontrolled components

Controlled vs. uncontrolled components - React.js Tutorial

From the course: React: Design Patterns

Controlled vs. uncontrolled components

- [Instructor] All right, so the next React design pattern that we're going to take a look at is controlled and uncontrolled components. Now, these are very, very common patterns to find in React, both of these, both controlled and uncontrolled components. So let's take a look at what both of these mean. First, let's start off by defining uncontrolled components. Uncontrolled components are basically React components where the component itself keeps track of all its own internal state, and really the only time we get data out of that component is when some event occurs. So this would be in the case of, let's say, a form when the user hits the Submit button. In an uncontrolled form, that would be the only time when we actually check what the values of the inputs of that form contain. Now, controlled components, on the other hand, are basically components where their parent is the one that takes care of keeping track of the state, and that state is then usually passed through to a…

Contents