Gives every component that loads from the API the same states, so that ListState renders loading, error and empty alike everywhere.

Type Aliases

T
LoadState<L extends object> =
{ status: "loading"; }
| { status: "error"; error: string; }
| ({ status: "loaded"; } & L)

Held by a page or hook for what it fetches, as useFetchState returns it, and passed to ListState. L is what the loaded state carries besides its status, as { data: T } for useFetchState or a feed's page fields.

Usage

import * as mod from "src/utils/shared/loadState.ts";