[]previous and next page

AwaitProps

<Await>: shows deferred data.

<Await>: shows deferred data. Renders fallback until resolve settles, then children(value); a rejection renders errorElement(error) (or rethrows to the nearest error boundary when there is none). It is Suspense and ErrorBoundary over a resource of the promise, so it streams like them: on the server a pending promise holds the stream of its boundary, and the browser claims the same markup.

Import#

ts
import type { AwaitProps } from "@shadow-js/dusk/client";

Signature#

ts
interface AwaitProps<T> {
  /** The data. A promise that is created once per `<Await>`; a new promise restarts the wait. */
  readonly resolve: PromiseLike<T>;
  /** Renders the value. Called untracked, once per settled value. */
  readonly children: (value: T) => unknown;
  /** Shown while the promise is pending. */
  readonly fallback?: unknown;
  /** Shown when the promise rejects; receives the error. Without it the error goes to the nearest boundary. */
  readonly errorElement?: (error: Error) => unknown;
}

Members#

Name Type Description
T T
resolve readonly resolve: PromiseLike<T> The data. A promise that is created once per <Await>; a new promise restarts the wait.
children readonly children: (value: T) => unknown Renders the value. Called untracked, once per settled value.
fallback? readonly fallback?: unknown Shown while the promise is pending.
errorElement? readonly errorElement?: (error: Error) => unknown Shown when the promise rejects; receives the error. Without it the error goes to the nearest boundary.