Skip to content

provide()

Make a createContext() value available to all descendant components. Call from inside a component() setup.

function provide<T>(context: Context<T>, value: T): void
ParamTypeDescription
contextContext<T>The context object returned by createContext()
valueTValue visible to descendant components via inject()
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.