Vigyata.AI
Is this your channel?

React 19 Tutorial - 26 - Sharing State Between Components

7.6K views· 210 likes· 12:16· Dec 1, 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 Lifting State Up and Sharing State Between Components in React 19

About This Video

Up until this point in the React 19 tutorial series, I’ve kept state inside a single component, which is perfectly fine for simple demos. But in real apps, multiple components often need to rely on the same changing data. In this video, I build a small shopping cart UI to show the problem: the ProductCard component can increment its own quantity, but the CartSummary has no idea anything changed, so it stays stuck on zero. To fix that, I walk you through lifting state up. I move the cart state into the closest common parent, the ShoppingCart component, and store quantities in an object so it scales to multiple products. Then I refactor ProductCard to become a controlled component: it receives name, price, quantity, and an onAddToCart handler as props. Finally, I update CartSummary to use the same shared cartItems state and a prices object to calculate total items and total price (including formatting with toFixed(2)). I also add a couple of practical touches—limiting a product quantity to 5 and a Clear Cart button—so you can see how the parent owns the rules and the children just follow along.

Frequently Asked Questions

🎬 More from Codevolution