import type { DependencyList } from 'react'; import type { UseDebouncedFnOptions } from "../use-debounced-fn/index.js"; import type { UseIntervalFnInterval } from "../use-interval-fn/index.js"; import type { UseLoadingSlowFnOptions, UseLoadingSlowFnReturns } from "../use-loading-slow-fn/index.js"; import type { Pausable } from "../use-pausable/index.js"; import type { UseReConnectOptions } from "../use-re-connect/index.js"; import type { UseReFocusOptions } from "../use-re-focus/index.js"; import type { UseRetryFnOptions } from "../use-retry-fn/index.js"; import type { UseThrottledFnOptions } from "../use-throttled-fn/index.js"; import type { AnyFunc, Gettable, Promisable } from "../utils/basic.js"; import type { UseQueryCacheLike } from "./use-query-cache.js"; export declare const defaultIsVisible: () => boolean; export declare const defaultIsOnline: () => boolean; export { mutate } from "./use-query-cache.js"; export type { UseQueryMutate, UseQueryCacheLike } from "./use-query-cache.js"; export interface UseQueryOptions>, E = any> extends Omit, 'initialValue'>, Pick, Pick { /** * Disable all automatic refresh behaviors, default is off * * @defaultValue false */ manual?: boolean; /** * Initial data passed to fetcher when first mount * * @defaultValue undefined */ initialData?: D | undefined; /** * Cache key, can be a string or a function that returns a string * * @defaultValue undefined */ cacheKey?: string | ((...args: Parameters | []) => string); /** * Max cache time, will clear the cache after the specified time * * default is 5_000 ms, set `false` to disable */ cacheExpirationTime?: number | false; /** * Cache provider, it can be set to an external store (reactive), localStorage, etc. * * Needs to comply with the UseQueryCacheLike interface definition, defaults to a globally shared `new Map()` * * @defaultValue global shared `new Map()` */ provider?: Gettable>; /** * ThrottleOptions => only affects the frequency of manually executing the run method * * @defaultValue undefined */ throttle?: UseThrottledFnOptions['wait'] | UseThrottledFnOptions; /** * DebounceOptions => only affects the frequency of manually executing the run method * * @defaultValue undefined */ debounce?: UseDebouncedFnOptions['wait'] | UseDebouncedFnOptions; /** * Whether to reload when focus is obtained, default is off * * @defaultValue false */ refreshOnFocus?: boolean; /** * Throttle time when obtaining focus, default 5_000 (ms), only valid when `refreshOnFocus` is true * * @defaultValue 5_000 */ refreshOnFocusThrottleWait?: number; /** * Custom visibility judgment function * * @defaultValue defaultIsVisible */ isVisible?: () => Promisable; /** * Whether to reload when network reconnects, default is off * * @defaultValue false */ refreshOnReconnect?: boolean; /** * Custom online judgment function * * @defaultValue defaultIsOnline */ isOnline?: () => Promisable; /** * Interval time for automatic refresh, default is 0, off * * @defaultValue 0 */ refreshInterval?: Exclude; /** * Whether to reload when hidden, default is off * * @defaultValue false */ refreshWhenHidden?: boolean; /** * Whether to reload when offline, default is off * * @defaultValue false */ refreshWhenOffline?: boolean; /** * The dependencies of the refresh operation, when the dependencies change, the refresh operation will be triggered * * @defaultValue [] */ refreshDependencies?: DependencyList; /** * Error retry count * * @defaultValue 0 */ errorRetryCount?: UseRetryFnOptions['count']; /** * Error retry interval * * @defaultValue `defaultRetryInterval` in `useRetryFn` */ errorRetryInterval?: UseRetryFnOptions['interval']; /** * Whether to clear the cache before each request * * @defaultValue undefined */ onErrorRetry?: UseRetryFnOptions['onErrorRetry']; /** * Callback executed when the request is canceled * * @defaultValue undefined */ onErrorRetryFailed?: UseRetryFnOptions['onRetryFailed']; } export interface UseQueryReturns>, E = any> extends Pausable, Omit, 'value'> { /** * The data returned by the request */ data: D | undefined; /** * Whether the request is in the initialization state (no data + loading, initializing => !data && loading) */ initializing: boolean; /** * Whether the request is refreshing data (has data + loading, refreshing => data && loading) */ refreshing: boolean; } /** * A basic React Hook for data fetching, supports cache, automatic refresh, and many awesome features. * * @since 1.5.0 */ export declare function useQuery>, E = any>(fetcher: T, options?: UseQueryOptions): UseQueryReturns;