useContext Purpose
Question
What does useContext do?
Hint
useContext consumes a Context created by createContext.
Explanation
useContext(MyContext) reads the current context value from the nearest Provider above. It eliminates prop drilling — passing props through intermediate components that do not need them. Create context with createContext(default), provide with <MyContext.Provider value={...}>. When the provider value changes, all consumers re-render. For performance, split contexts or use memoization. useContext must be called inside a component.
Related Resources
Related Lessons
- useContext
Learn useContext.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.