ExternalStoreOptions
Options of useExternalStore.
Options of useExternalStore.
Import#
ts
import type { ExternalStoreOptions } from "@shadow-js/core";
Signature#
ts
interface ExternalStoreOptions<T> {
/**
* The snapshot the server renders (there is no subscription there). Without it the server reads
* `getSnapshot` once. Keep it equal to what the browser reads on its first render: a difference is
* corrected only after subscribing, and no hydration test covers that case yet. While hydrating,
* the browser's first render also uses it.
* @default undefined (the server, and hydration, read `getSnapshot`)
*/
getServerSnapshot?: () => T;
/**
* Decides whether a new snapshot is a change: the accessor updates only when it returns `false`.
* @default Object.is
*/
equals?: Equals<T>;
/**
* Label shown by devtools and diagnostics.
* @default undefined (the store is unnamed)
*/
name?: string;
}
Members#
| Name | Type | Description |
|---|---|---|
T |
T |
|
getServerSnapshot? |
getServerSnapshot?: () => T |
The snapshot the server renders (there is no subscription there). Without it the server reads getSnapshot once. Keep it equal to what the browser reads on its first render: a difference is corrected only after subscribing, and no hydration test covers that case yet. While hydrating, the browser's first render also uses it. |
equals? |
equals?: Equals<T> |
Decides whether a new snapshot is a change: the accessor updates only when it returns false. |
name? |
name?: string |
Label shown by devtools and diagnostics. |