[]previous and next page

SUSPENSION

The value a reader throws when a transition reads data that is still loading inside a Suspense boundary that is showing content.

The value a reader throws when a transition reads data that is still loading inside a Suspense boundary that is showing content. The reader keeps its previous value (a memo keeps its value, an effect leaves the DOM as it is) until the boundary releases it. A single frozen object: identity is the test, so user code cannot forge it. holdReader throws it for you; a custom primitive that catches errors must let it through, which isSuspension checks.

Import#

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

Signature#

ts
const SUSPENSION: { readonly suspended: true }

Examples#

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

function rethrowIfHeld(error: unknown): void {
  if (error === SUSPENSION) throw error; // not a failure: the boundary resumes the reader later
}