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 "Action & State Modification 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 build a new action, dispatch the action, and modify the state.

Get Unlimited Access Now

Transcript from the "Action & State Modification Exercise" Lesson

[00:00:00]
>> What I'd love for you to do, is try to now dispatch an action when the forgiven checkbox has been checked. Right, so what's Forgiveness to actually doing the state management, to just announcing, hey, forgiveness has been issued. We have issued a pardon for whoever parts too close to me in the parking lot.

[00:00:23] It's not really that person's fault, it's the parking lot spaces, it's not important. We're gonna issue forgiveness to that person. We'll basically, instead of actually doing it all in there, we want to move it up into the reducer, and we want to just say that it happened. So we added the ability add a grudge, all right?

[00:00:42] It would be great if we could also forgive the graduates and notice that like I took on adding the graduate level to you to deal with forgiveness. I am a small person and you're all better than me. And so, what we wanna do is in the same way that we refactored addGrudge to instead of dealing with the fact that grudge changed to simply announce that it happened, and take this entirely very easily testable, JavaScript function, to deal with what that means.

[00:01:09] I would implore you to do the same. Right, we'll get the idea in here, to do the same, to say, okay, a grudge has been forgiven, your job is to dispatch that announcement, right? And then in the reducer, which receives announcements like okay, if this is an announcement that a grudge has been forgiven, go ahead and we're gonna manage our state appropriately, right?

[00:01:31] And some of the inspiration of how to do this can be found right in here as well, like you'll have to do a little bit of change, right? Here we call it state, which we have it and we rename grudges, if you want, there's reasons why we might not want to later on.

[00:01:43] The same basic idea, just pull that through as well.