From the course: React for Web Designers
Unlock this course with a free trial
Join today to access over 22,600 courses taught by industry experts.
Forms in React: Controlled or not - React.js Tutorial
From the course: React for Web Designers
Forms in React: Controlled or not
- [Instructor] The next step we'll be taking is updating our little app's state based on what happens in our filter form here. But before we do that let's take a brief pause to talk about the two main ways that you can work with forms in React. Specifically, we're going to be talking about controlled versus uncontrolled form elements. What we're asking here is who is the source of truth for the form data? It can either be React state or it can be the DOM elements that comprise the form. First, we'll talk about controlled components. A controlled form component is one where React is the source of truth or more specifically, React's state is the source of truth. That means that your code controls whether the form value changes. So, for example, you can do validation in your React code and then not update the state of the element that you're validating and the value won't change no matter what the user has typed. When you're working with controlled components every piece of state works…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Use the mockup, make a plan6m 9s
-
(Locked)
Scaffold initial components5m 58s
-
(Locked)
Functional components6m 37s
-
(Locked)
Build the filters form5m 41s
-
(Locked)
Forms in React: Controlled or not2m 53s
-
(Locked)
Wire up the filters form10m 57s
-
(Locked)
Respond to filter form updates5m 33s
-
(Locked)
Animating with ReactTransitionGroup8m 21s
-
(Locked)
Challenge: Better usability and animation3m 11s
-
(Locked)
Solution: Better usability and animation5m
-
(Locked)
-
-