GraphReFlyTS

API Reference

externalStore()

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

Import

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

Signature

function externalStore(
	node: Node<T>,
	opts: Pick<SubscribeValuesOptions<T>, "getSnapshot" | "onError" | "onComplete"> = {},
): ExternalStore<T>

Parameters

ParameterTypeDescription
nodeNode<T>Node to observe, adapt, or connect.
optsPick<SubscribeValuesOptions<T>, "getSnapshot" | "onError" | "onComplete">Options that configure the helper.

Returns

A ExternalStore<T> value.

Example

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

Source

packages/ts/src/adapters/store.ts