From the course: React: Components, Context, and Accessibility

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Uncontrolled components

Uncontrolled components - React.js Tutorial

From the course: React: Components, Context, and Accessibility

Start my 1-month free trial

Uncontrolled components

- [Instructor] In this video we'll take a look at one way to build a form using an uncontrolled component. With an uncontrolled component you'll use dom elements directly to build your form. And then to capture input values we'll use refs. So let's first get rid of this display stuff from before instead we're going to render a component called encouragement form, this is gonna encourage us to keep programming, and, we'll say encouragement form extends react component, of course this is gonna render something we will render a form. Now the form should have a label and inside of that label we will add the label text so we'll say send an encouraging message and we'll add the input at this level as well. So this will have a type of text, and then we'll use the ref, we'll use input, then we'll say this.input equals input. So this is gonna allow us to capture whatever the value is that is entered into that field. Now finally we want to add a button here, our button is simply going to wrap…

Contents