API reference › @evolu/react › createRunBinding
function createRunBinding<R>(): {
RunContext: FC<{
children?: ReactNode;
value: Run<R extends DisposableRun<D> ? D : never>;
}>;
useRun: () => Run<R extends DisposableRun<D> ? D : never>;
};
Defined in: Task.tsx:39
Creates typed React Context and hook for Run.
The DisposableRun type argument is used to infer the deps type for the returned API, which exposes only Run.
useRun throws when the provider is missing.
Example
const run = createRun(createEvoluDeps());
const { RunContext, useRun } = createRunBinding<typeof run>();
<RunContext value={run}>
<App />
</RunContext>;
// In a component
const run = useRun();
Testing
const testRun = testCreateRun({ api: testApi });
const { RunContext } = createRunBinding<typeof testRun>();
<RunContext value={testRun}>
<MyComponent />
</RunContext>;