UNPKG

@dev-fastn-ai/react-core

Version:

React hooks and components for integrating Fastn AI connector marketplace into your applications. Built on top of @fastn-ai/core with React Query for optimal performance.

37 lines (36 loc) 1.31 kB
import type { ConnectorField, SelectOption } from "@dev-fastn-ai/core"; /** * Custom hook to manage async select field options with search, pagination, and error handling using React Query. * * Benefits of React Query caching: * - Automatic caching with configurable stale time (5 minutes) * - Background refetching when data becomes stale * - Deduplication of requests * - Optimistic updates * - Automatic retry on failure * - Cache invalidation and garbage collection * * @param field ConnectorField - The field definition containing optionsSource * @returns { options, loading, loadingMore, hasNext, query, refresh, search, loadMore, error } * * @example * ```tsx * const { options, loading, loadingMore, hasNext, search, loadMore } = useFieldOptions(field); * * // Options are automatically cached and shared across components * // Loading states are handled automatically * // Pagination is managed with infinite query * ``` */ export declare function useFieldOptions(field: ConnectorField): { options: SelectOption[]; loading: boolean; loadingMore: boolean; hasNext: boolean; query: string; refresh: () => Promise<void>; search: (query: string) => void; loadMore: () => Promise<void>; totalLoadedOptions: number; error: string | null; };