Context API
Built-in React state sharing without prop drilling
Key Concepts
- createContext() to define a context
- Context.Provider wraps components to share state
- useContext() hook to consume context values
- Best for theme, auth, and low-frequency updates
- Avoid performance issues by splitting contexts
Click the icon to change the global theme:
(The same behaviour can be achieve by clicking in navbar )