State Management in Pure React, v2 useEffect Exercise
This course has been updated! We now recommend you take the React Performance course.
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.