function useFetchState
useFetchState<T>(
key: string | undefined,
load: (signal: AbortSignal) => Promise<T>,
unnamed 2?: FetchStateOptions<T>
): UseFetchStateResult<T>

Returns what load resolves to for key, loaded the first time it is enabled, and kept afterwards. A new key starts over and aborts the load of the last one, as leaving the page does; an undefined key loads nothing. The key must change with whatever the load depends on, the viewer included when it is signed in. load must reject with an Error, as expectOk does, whose message it shows.

Type Parameters

Parameters

key: string | undefined
load: (signal: AbortSignal) => Promise<T>
optional
unnamed 2: FetchStateOptions<T>

Return Type

Usage

import { useFetchState } from "src/hooks/shared/useFetchState.ts";