useProvide
Provide state to child components
API Reference
Syntax
useProvide("count", 0);Parameters
key: Global state key to provide to child componentsvalue: State value
Example
function App() {
useProvide("count", 0); // Provide state to child components
return <Child />;
}
function Child() {
const count = useInject<number>("count"); // Inject state
return <div>Count: {count}</div>;
}Notes
useProvideautomatically cleans up state on component unmount, no manual cleanup required.useProvideanduseInjectoperate on global state, not isolated by component tree.