[]previous and next page

beginHold

Starts a Suspense hold: the boundary keeps showing its current content while a transition waits for data.

Starts a Suspense hold: the boundary keeps showing its current content while a transition waits for data. Holds are counted, and the running transitions stay pending (isPending of useTransition, the promise of startTransition) until every hold has ended. For renderers that implement Suspense; each call needs one endHold. Does nothing before the transition machinery exists (no transition has run).

Import#

ts
import { beginHold } from "@shadow-js/core/extend";

Signature#

ts
function beginHold(): void

Examples#

ts
import { beginHold, endHold, wakeSuspended } from "@shadow-js/core/extend";

export function holdUntil(data: Promise<unknown>): void {
  beginHold(); // the boundary keeps its content
  void data.finally(() => {
    wakeSuspended();
    endHold();
  });
}