useContext(). No prop threading required.
createContext()
Create a context object that can hold a typed value.Signature
Parameters
Returns
Context<T> — an object with a Provider method for providing values and internal state for useContext() lookups.
useContext()
Read the current value from the nearest Provider in the component tree.Signature
Parameters
Returns
The current context value from the nearest Provider, the default value if no Provider is active, orundefined if neither exists.
Provider
Provide a value to all descendants. Two usage patterns are supported:JSX usage
Callback usage
Pattern: typed accessor hook
Always create ause* wrapper that throws on missing Provider. This gives consumers a clear error instead of silent undefined.