[]previous and next page

HydrationScope

A hydration scope: the deterministic source of hydration keys shared by the server renderer and the client hydrator.

A hydration scope: the deterministic source of hydration keys shared by the server renderer and the client hydrator. Keys depend only on the nesting and order of component calls, never on owners, effects or memos, so server and client agree as long as they run the same components. Scopes are created by createRootScope, enterComponent and childScope; treat their fields as read-only.

Import#

ts
import type { HydrationScope } from "@shadow-js/web/extend";

Signature#

ts
interface HydrationScope {
  /** Prefix of every key allocated in this scope, ending with `-` (`"0-"` for a root, `"0-3-"` below). */
  readonly id: string;
  /** Next number handed out by this scope: component scopes and template root keys share it. */
  count: number;
  /** Number of auto-keyed resources created directly in this scope so far. */
  resources: number;
}

Members#

Name Type Description
id readonly id: string Prefix of every key allocated in this scope, ending with - ("0-" for a root, "0-3-" below).
count count: number Next number handed out by this scope: component scopes and template root keys share it.
resources resources: number Number of auto-keyed resources created directly in this scope so far.