provide()
Make a createContext() value available to all descendant components. Call from inside a component() setup.
Signature
Section titled “Signature”function provide<T>(context: Context<T>, value: T): voidParameters
Section titled “Parameters”| Param | Type | Description |
|---|---|---|
context | Context<T> | The context object returned by createContext() |
value | T | Value visible to descendant components via inject() |
Examples
Section titled “Examples”import { createContext, provide, component, div } from "@whisq/core";
const ThemeCtx = createContext("light");
const App = component(() => { provide(ThemeCtx, "dark"); return div(Page({}));});See inject() for the consumer side and Components → Context for the full pattern.