From the course: React Hooks

Unlock the full course today

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

Managing form inputs with useRef

Managing form inputs with useRef - React.js Tutorial

From the course: React Hooks

Start my 1-month free trial

Managing form inputs with useRef

- [Instructor] As we move our way through all of these different hooks that the React library provides us with, one that we can't overlook is useRef. So useRef is going to allow us to reach out to a component and determine its value. And this can be extremely useful, particularly with forms. So the first thing I want to do with our form is I want to import useRef. I'll get rid of all of our reducer stuff from before. Then inside of the component, instead of returning this here, we're going to say form and we'll close the form. Inside the form, I want to add an input with a type of text and then we'll add another one of these with a type color. Then I need to get rid of useReducer because we're getting those errors. Let's just make sure that this is rendering okay. Yeah, so we have our little input fields and then we have a little color picker. Let's also create a button, and the button should have text that says add. So this…

Contents