From the course: React: State Management (2019)

Unlock the full course today

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

Implementing Hooks

Implementing Hooks - React.js Tutorial

From the course: React: State Management (2019)

Start my 1-month free trial

Implementing Hooks

- [Presenter] A new feature to manage state is React Hooks. It was recently added in React 16.8. To explore this more, let's take a look at our footer component in our application. Now, suppose in addition to the number of books that we've read, that we'd like to add a goal of the number of books we'd like to read. Let's go ahead and modify our footer with a couple of buttons that'll allow us to increment and decrement our goal number of books that we'd like to read. I'm going to go ahead an do that now. So instead of Toggle Authors, this is going to be Increment. And instead of Toggle Authors here, we're going to say Decrement. Now let's not worry about the setState for now. We'll come back to it. With our understanding of React, it would make sense that, in order to keep track of a counter state, that we would want to go ahead and refactor this component. If we were to do that, it would probably look something like this. Class footer extends component. And then we'd probably do…

Contents