UNPKG

@supunlakmal/hooks

Version:

A collection of reusable React hooks

18 lines (17 loc) 750 B
import { FetchState } from './useFetch'; interface UseIdleFetchOptions { idleTimeout: number; fetchOptions?: RequestInit; idleDebounce?: number; } /** * A hook that combines useIdleTimer and useFetch to trigger a data fetch * only when the user becomes active after a period of inactivity. * * @template T The expected data type from the fetch request. * @param targetUrl The URL to fetch data from when the user becomes active. * @param options Configuration options including idleTimeout and optional fetchOptions/idleDebounce. * @returns The result object from useFetch ({ data, error, loading }). */ export declare function useIdleFetch<T = unknown>(targetUrl: string, options: UseIdleFetchOptions): FetchState<T>; export {};