useContext
Edit this pageUsed to grab context within a context provider scope to allow for deep passing of props without having to pass them through each Component function.
It's therefore used in conjunction with createContext
to consume the data from a Provider scope and thus avoid passing data through intermediate components (prop drilling).
Recommended usage
It is often a good idea to wrap useContext
in a function like so:
See the API reference of createContext the API on how to generate a Provider scope. And check the Context concepts for more information on how to architecture your contexts.