externalStore()
Build the tiny shape React’s useSyncExternalStore expects, without importing React.
Import
Section titled “Import”import { externalStore } from "@graphrefly/ts/adapters";Signature
Section titled “Signature”function externalStore( node: Node<T>, opts: Pick<SubscribeValuesOptions<T>, "getSnapshot" | "onError" | "onComplete"> = {},): ExternalStore<T>Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
node | Node<T> | Node to observe, adapt, or connect. |
opts | Pick<SubscribeValuesOptions<T>, "getSnapshot" | "onError" | "onComplete"> | Options that configure the helper. |
Returns
Section titled “Returns”A ExternalStore<T> value.
Example
Section titled “Example”import { externalStore } from "@graphrefly/ts/adapters";Source
Section titled “Source”packages/ts/src/adapters/store.ts