What is React Context API and how do you use it?
Instruction: Describe the purpose of the Context API in React and provide an example of how it can be used to manage global state.
Context: This question tests the candidate's ability to work with React's Context API for managing global application state without prop drilling.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
Context passes a value through a React tree without requiring each intermediate component to forward it. It is useful for a shared theme or dependency. State still belongs to a component or store; context itself does not persist data or create one universal global state.
This complete module scopes a theme to a provider:...
Related Questions
-
medium
-
medium
-
hard
-
hard