Skip to content
PACKAGES

externalStore()

Build the tiny shape React’s useSyncExternalStore expects, without importing React.

import { externalStore } from "@graphrefly/ts/adapters";
function externalStore(
node: Node<T>,
opts: Pick<SubscribeValuesOptions<T>, "getSnapshot" | "onError" | "onComplete"> = {},
): ExternalStore<T>
ParameterTypeDescription
nodeNode<T>Node to observe, adapt, or connect.
optsPick<SubscribeValuesOptions<T>, "getSnapshot" | "onError" | "onComplete">Options that configure the helper.

A ExternalStore<T> value.

import { externalStore } from "@graphrefly/ts/adapters";

packages/ts/src/adapters/store.ts