Context API
The Context API is React’s built-in solution for sharing global state across components without manually passing props through every level of the component tree.
Creating a Context
Providing Context Values
A Provider component wraps the part of your app that needs access to the shared state, supplying the actual value to all nested components.
Consuming Context with useContext
Building a Custom Context Hook
Wrapping useContext in a custom hook improves readability and provides a single place to add error checks if the context is used outside its Provider.
When to Use Context API
Context API works well for relatively simple global state such as themes, authentication status, or language preferences, but can lead to unnecessary re-renders in large apps with frequently changing state.
Limitations of Context API
Every component consuming a context re-renders whenever the context value changes, which can cause performance issues in large applications with deeply nested consumers and frequent updates.
Conclusion
The Context API is a powerful built-in tool for moderate global state needs in React Native. For simpler applications, it often eliminates the need for a third-party library like Redux entirely.

