Vigyata.AI
Is this your channel?

React 19 Tutorial - 35 - Context with State

3.6K views· 128 likes· 7:50· Dec 16, 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 Context with State

About This Video

In this video, I take our React 19 context example one step further. Context is great for eliminating prop drilling, but in real apps you rarely just read from context—you almost always need to update it too. Think theme toggles, logout buttons, or language switchers buried deep in the component tree. If your context only exposes a static object, components like Avatar can display data, but they can’t change anything. So I combine context with state by moving the user object into useState and then passing both the state (user) and the setter (setUser) through the context value. After that, I show a cleaner, scalable pattern: creating a custom UserContextProvider component that encapsulates the state logic and keeps App nice and lightweight. Finally, I update Avatar (sitting four levels deep) to toggle the theme between dark and light using setUser—without passing a single prop. The key takeaway is simple: once you pass both state and its updater through context, your context becomes dynamic, editable, and accessible anywhere in the tree. This same idea also works with useReducer by passing state and dispatch.

Frequently Asked Questions

🎬 More from Codevolution