This course has been updated! We now recommend you take the React Performance course.

Check out a free preview of the full State Management in Pure React, v2 course:
The "useEffect Exercise" Lesson is part of the full, State Management in Pure React, v2 course featured in this preview video. Here's what you'd learn in this lesson:

The students are instructed to read the initial value of state and store it as an object using useEffect.

Get Unlimited Access Now

Transcript from the "useEffect Exercise" Lesson

>> What I want us to do for this exercise is we've set the document title use a useEffect. What we'll do in this case is we're also now going to set local storage as well, right? And there'll be a few things here. One, is that we can just register a second effect and without having to have a second method and the callback, which will be nice and we just do it in one place.

[00:00:18] So what we wanna do is we are gonna need to kinda refactor this code slightly, we are storing the full object in there. Which means we could do something along the lines of changing this for count. In this case we'll change this to count and store as an object as well.

[00:00:38] So you're gonna that from state as initial value, you're going to use useEffect to store it, and then we'll take a look at it together.