API reference@evolu/react › createRunBinding

function createRunBinding<D>(run: Run<D>): {
  RunContext: FC<{
    children?: ReactNode;
    value: Run<D>;
  }>;
  useRun: () => Run<D>;
};

Defined in: Task.tsx:38

Creates typed React Context and hook for Run.

The run argument is used to infer the deps type for the returned API.

useRun throws when the provider is missing.

Example

const run = createRun(createEvoluDeps());
const { RunContext, useRun } = createRunBinding(run);

<RunContext value={run}>
  <App />
</RunContext>;

// In a component
const run = useRun();

Testing

const testRun = testCreateRun({ api: testApi });
const { RunContext } = createRunBinding(testRun);

<RunContext value={testRun}>
  <MyComponent />
</RunContext>;