Skip to main content

Function: StackProvider()

function StackProvider(props): Element;

Defined in: react/src/components/StackProvider/index.tsx:117

A provider component that initializes the DocStack client and makes it available to child components via the useDocStack hook.

The config prop is reconciled rather than read once: a stack that appears in it is opened, a stack that disappears is closed, and the stacks either side of the change are left running. An application whose set of databases grows at runtime - one per workspace, say - therefore does not have to reload to pick up a new one, which matters once each stack also carries a live replication that a reload would drop.

Parameters

ParameterType
propsDocStackProviderProps

Returns

Element

Example

import { StackProvider } from '@docstack/react';

const App = () => {
const workspaces = useWorkspaces();
const config = useMemo(
() => [{ name: 'app' }, ...workspaces.map(w => ({ name: `ws-${w.slug}` }))],
[workspaces]
);
return (
<StackProvider config={config}>
<MyApp />
</StackProvider>
);
};