Check out a free preview of the full Redux Fundamentals (feat. React) course

The "Dispatching from Forms Exercise" Lesson is part of the full, Redux Fundamentals (feat. React) course featured in this preview video. Here's what you'd learn in this lesson:

Students are instructed to implement the SetCounter form to update the state.

Preview
Close

Transcript from the "Dispatching from Forms Exercise" Lesson

[00:00:00]
>> So we're gonna do another kind of little example here, which is before he just had to add some onClick handlers with the dispatch, I was fine. It was nice to get us warmed up. But here we have something a little bit more complicated and by a little bit mean just slightly, we're gonna have a little bit of a form and this form is going to allow them to set the count to any given number.

[00:00:23]
All right, so it's going to the simplest version could just be an input field that we dispatch, based on whatever is in that field. We can dispatch the set action that we created earlier. If you wanna take it for an extension, it would be cool, if we could also like, if it reflected the current number that we have in the counter as well.

[00:00:44]
So the counter is 45, the value of the input field was 45 as well, right? That's going to be a little bit trickier, but either way we will do it together. So which was trying to implement the set counter, the one thing you're gonna need to do is go into counter, just add this set counter here as well.

[00:01:04]
And we should be able to go ahead and now see that we have in the application. We'd love to get this working so that when it hits submit, we can change the count. Originally, we can just keep this as some amount of state, but if you can actually kinda sync it up with the actual account that would be really cool as well.

[00:01:22]
Awesome.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now