Redux Fundamentals (feat. React)

Updating Item Data Solution

Steve Kinney

Steve Kinney

Temporal
Redux Fundamentals (feat. React)

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

The "Updating Item Data Solution" 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:

Steve live codes the solution to the Updating Item Data exercise.

Preview
Close

Transcript from the "Updating Item Data Solution" Lesson

[00:00:00]
>> All right, so our job was basically to do something very similar to what we did before, but we need to get the quantity work. And this is kind of, we can kind of stand on the spot to say stand on the shoulder of giants. That seems really not okay when I'm the giant seems like very self aggrandizing.

[00:00:19]
In fact, let's go with this and on the shoulders of giants on the giant this case, update quantity is simply going to, we'll eventually have an update quantity action here as well and it's gonna change the quantity. It's basically a lot of the same except we are updating the price we're gonna do the quantity.

[00:00:42]
So actually pop that in as well. If anyone sees miss type the word quantity at some point you let me know, because that's not outside the realm of possibility. So we've got update quantity in our map dispatch to props and now we will move into our actions or again, it's very much a little bit the same here.

[00:01:05]
Where well update quantity. And I'm sure you could get very fancy here, and make some kind of abstraction. When things will see in Redux toolkit, is there is the ability to kind of like there's a. You can use this Redux toolkit or there's libraries that do this, which will be like create action where you give it just the name and it will prepare the payload for you.

[00:01:37]
Item quantity updated. As well, so we can put that in. So, now I've got the action creator, we're mapping it to dispatch, we do need to add it into the reducer, and that should be quantity. Make sure to, I knew I was gonna miss it somewhere. This is I'd like to say it's a test but probably a mistake when if I leave price or misspell quantity at some point.

[00:02:06]
There's speaking of misspelling quantity there it is. Misspelled that and looks like we have it ready to go and our actions. We've got it ready going our dispatch, we just really need to reduce our logic and that should do the trick of for us. So we'll say, we'll pull in this item quantity updated that we just made.

[00:02:30]
And, we will grab this last reducer, that piece of reducer logic. As well, and here will change. All right, now is the test to see where I misspelled something. So go in here as well. All right, I should be able, it works, I got it right on the first try.

[00:03:02]
All right, that's a pleasant surprise. Cool.

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