@refinedev/core
Version:
Refine is a React meta-framework for building enterprise-level, data-intensive applications rapidly with support for modern UI libraries and headless integrations.
61 lines • 3.44 kB
TypeScript
import { type QueryObserverResult, type UseQueryOptions } from "@tanstack/react-query";
import type { BaseRecord, CrudFilter, CrudSort, GetListResponse, HttpError, MetaQuery, Pagination, Prettify } from "../../contexts/data/types";
import type { LiveModeProps } from "../../contexts/live/types";
import type { SuccessErrorNotification } from "../../contexts/notification/types";
import { type UseLoadingOvertimeOptionsProps, type UseLoadingOvertimeReturnType } from "../useLoadingOvertime";
import type { MakeOptional } from "../../definitions/types/index";
export type BaseListProps = {
/**
* Pagination properties
*/
pagination?: Pagination;
/**
* Sorter parameters
*/
sorters?: CrudSort[];
/**
* Filter parameters
*/
filters?: CrudFilter[];
/**
* Meta data query for `dataProvider`
*/
meta?: MetaQuery;
/**
* If there is more than one `dataProvider`, you should use the `dataProviderName` that you will use
*/
dataProviderName?: string;
};
export type UseListQueryOptions<TQueryFnData, TError, TData> = MakeOptional<UseQueryOptions<GetListResponse<TQueryFnData>, TError, GetListResponse<TData>>, "queryKey" | "queryFn">;
export type UseListProps<TQueryFnData, TError, TData> = {
/**
* Resource name for API data interactions
*/
resource?: string;
/**
* Tanstack Query's [useQuery](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) options
*/
queryOptions?: UseListQueryOptions<TQueryFnData, TError, TData>;
} & BaseListProps & SuccessErrorNotification<GetListResponse<TData>, TError, Prettify<BaseListProps>> & LiveModeProps & UseLoadingOvertimeOptionsProps;
export type UseListReturnType<TData, TError> = {
query: QueryObserverResult<GetListResponse<TData>, TError>;
result: {
data: TData[];
total: number | undefined;
[key: string]: any;
};
} & UseLoadingOvertimeReturnType;
/**
* `useList` is a modified version of `react-query`'s {@link https://tanstack.com/query/v5/docs/framework/react/guides/queries `useQuery`} used for retrieving items from a `resource` with pagination, sort, and filter configurations.
*
* It uses the `getList` method as the query function from the `dataProvider` which is passed to `<Refine>`.
*
* @see {@link https://refine.dev/docs/api-reference/core/hooks/data/useList} for more details.
*
* @typeParam TQueryFnData - Result data returned by the query function. Extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#baserecord `BaseRecord`}
* @typeParam TError - Custom error object that extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#httperror `HttpError`}
* @typeParam TData - Result data returned by the `select` function. Extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#baserecord `BaseRecord`}. Defaults to `TQueryFnData`
*
*/
export declare const useList: <TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TData extends BaseRecord = TQueryFnData>({ resource: resourceFromProp, filters, pagination, sorters, queryOptions, successNotification, errorNotification, meta, liveMode, onLiveEvent, liveParams, dataProviderName, overtimeOptions, }?: UseListProps<TQueryFnData, TError, TData>) => UseListReturnType<TData, TError> & UseLoadingOvertimeReturnType;
//# sourceMappingURL=useList.d.ts.map