Vigyata.AI
Is this your channel?

React 19 Tutorial - 29 - useReducer (complex state and actions)

5.4K views· 145 likes· 20:57· Dec 9, 2025

🛍️ Products Mentioned (2)

Github - https://github.com/gopinav/React-19-Tutorials Become a Fullstack Developer with Scrimba - https://scrimba.com/fullstack-path-c0fullstack?via=Codevolution Follow me + Twitter - https://twitter.com/CodevolutionWeb Business - codevolution.business@gmail.com React 19 useReducer (complex state and actions)

About This Video

In the previous lesson, I used useReducer with a simple counter where the state was just a number and actions were just strings. That’s great for learning the fundamentals, but real apps don’t stay that simple. In this video, I show you how useReducer works when your state has multiple related values and your actions need to carry extra data using an action object with a type and a payload. To make it practical, I build a small shopping cart. We model complex state with an items array, totalAmount, and totalItems, and then handle common cart operations: add item (including the “already in cart” quantity increment case), remove item, update quantity (with a neat reuse trick: if quantity hits zero, dispatch the remove logic), and clear cart. The big takeaway is that all related state updates stay centralized in the reducer, so totals and item quantities stay in sync. And remember: most of this is just JavaScript array/object logic—React is simply calling your reducer and giving you state + dispatch.

Frequently Asked Questions

🎬 More from Codevolution