From the course: React Hooks

Unlock the full course today

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

Incorporating the useState Hook

Incorporating the useState Hook - React.js Tutorial

From the course: React Hooks

Start my 1-month free trial

Incorporating the useState Hook

- [Instructor] Now that we understand array destructuring a little bit more, let's go ahead and get rid of this array. We're also going to get rid of this name in our app. And just to keep everything on the same screen, I'm also going to not import my app from that app file. I'm just going to create it right here in the index. So what we want to do in this video is we want to add state to our App component. And the way that we do this with React hooks is we're going to use a function. Let's first go ahead and return a div. Inside of the div, let's say the package is and I'll give that a save. And the next thing I want to do is I want to create a constant here on line six and I'll going to call this results and I'm going to call the function useState. If I want to use useState, I also need to import it from the React library and this is a function, so we're going to import it inside of these curly braces. So…

Contents