UNPKG

arcx

Version:

A lightweight, dependency-free fetch utility for APIs and React.

20 lines 721 B
import { FetchOptions } from "./fetchRequest"; /** * A minimal Suspense-compatible hook that throws a promise until data is loaded, * or throws an error if there's a failure. * * @template T - The expected shape of the fetched data. * @param url - The resource URL. * @param options - Additional fetch options. * @returns The fetched data of type T. * * @example * function MyComponent() { * const data = useFetchSuspense<MyData>("/api/data"); * return <div>{JSON.stringify(data)}</div>; * } * * // Then wrap <MyComponent /> in a <Suspense fallback={...} /> boundary */ export declare function useFetchSuspense<T>(url: string, options?: FetchOptions): T; //# sourceMappingURL=useFetchSuspense.d.ts.map