UNPKG

@croct/plug-react

Version:

React components and hooks to plug your React applications into Croct.

21 lines (18 loc) 1.01 kB
import { VersionedSlotMap, VersionedSlotId, SlotContent } from '@croct/plug/slot'; import { JsonObject } from '@croct/plug/sdk/json'; import { FetchOptions } from '@croct/plug/plug'; type UseContentOptions<I, F> = FetchOptions<F> & { initial?: I; cacheKey?: string; expiration?: number; staleWhileLoading?: boolean; }; type UseContentHook = { <P extends JsonObject, I = P, F = P>(id: keyof VersionedSlotMap extends never ? string : never, options?: UseContentOptions<I, F>): P | I | F; <S extends VersionedSlotId>(id: S, options?: UseContentOptions<never, never>): SlotContent<S>; <I, S extends VersionedSlotId>(id: S, options?: UseContentOptions<I, never>): SlotContent<S> | I; <F, S extends VersionedSlotId>(id: S, options?: UseContentOptions<never, F>): SlotContent<S> | F; <I, F, S extends VersionedSlotId>(id: S, options?: UseContentOptions<I, F>): SlotContent<S> | I | F; }; declare const useContent: UseContentHook; export { type UseContentOptions, useContent };