6 min read
•Question 10 of 48mediumuseContext Hook
Sharing state without prop drilling.
What is Context?
Context provides a way to pass data through the component tree without passing props manually at every level.
When to Use Context
- Theme data (dark/light mode)
- User authentication
- Language preferences
- Any global state
Context API Steps
- Create context with
createContext - Provide value with
Provider - Consume with
useContext