Vigyata.AI
Is this your channel?

React 19 Tutorial - 36 - use API for Context

4.7K views· 139 likes· 4:14· 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 use API for Context in React 19

About This Video

In this lesson, I show you how React 19’s new `use` API can be used as a more flexible alternative to `useContext` for consuming context values. We’ve already been reading user data from context in the Avatar component using `useContext`, and everything works fine. The nice part is how small the change is: import `use` from React, replace `useContext(UserContext)` with `use(UserContext)`, and you get the exact same result in the browser—same behavior, same output. The real reason `use` is interesting is that it’s not a hook, so it doesn’t have to follow the Rules of Hooks. That means I can call it anywhere in the component—even after an early return. I demonstrate a very common scenario: showing a loading UI when user data is still being fetched. With `use`, I can return early when `isLoading` is true, and React is completely fine with it. There’s also a subtle performance win: if we return early, the `use` call never runs, so React doesn’t even need to walk up the tree to find the provider. To wrap it up, `use` does the same job as `useContext`, but without the hook restrictions—so while `useContext` will stay common in React 18 codebases, `use` will likely show up a lot more in new React 19 apps.

Frequently Asked Questions

🎬 More from Codevolution