Vigyata.AI
Is this your channel?

React 19 Tutorial - 34 - Context and useContext Hook

4.8K views· 165 likes· 8:19· Dec 15, 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 Context and useContext Hook in React 19

About This Video

In the last lesson, we talked about prop drilling — passing the same data through multiple layers of components even though only one component actually needs it. In this video, I show you how React solves that problem using Context and the useContext hook. Context lets you share data across your component tree without manually forwarding props through every intermediate component. Think of it like broadcasting a value at a high level, and any nested component can subscribe to it directly. To make it crystal clear, I first recreate the prop drilling scenario with a simple “header section” component tree: App -> Header -> NavigationBar -> UserMenu -> Avatar. The user object (Bruce Wayne, admin, dark theme) travels through multiple components that don’t use it, just to reach Avatar — the only component that actually needs it. Then we replace all those unnecessary props with context. I create a userContext with createContext, wrap the tree with the provider in App, pass the user object via the value prop, and consume it in Avatar using useContext. I also show what happens when you remove the provider (you’ll get undefined), and how a default value in createContext can act as a fallback (useful for isolated testing). In real apps though, you typically want the provider because the default value is static. Next up, we’ll combine context with state to make the data dynamic and updatable.

Frequently Asked Questions

🎬 More from Codevolution