import { RaRecord, GetOneParams } from '../types'; import { UseQueryOptions, UseQueryResult } from 'react-query'; /** * Call the dataProvider.getOne() method and return the resolved value * as well as the loading state. * * The return value updates according to the request state: * * - start: { isLoading: true, isFetching: true, refetch } * - success: { data: [data from response], isLoading: false, refetch } * - error: { error: [error from response], isLoading: false, refetch } * * This hook will return the cached result when called a second time * with the same parameters, until the response arrives. * * @param resource The resource name, e.g. 'posts' * @param {Params} params The getOne parameters { id, meta }, e.g. { id: 123 } * @param {Options} options Options object to pass to the react-query queryClient. * * @typedef Params * @prop id a resource identifier, e.g. 123 * * @typedef Options * @prop enabled Flag to conditionally run the query. If it's false, the query will not run * @prop onSuccess Side effect function to be executed upon success, e.g. { onSuccess: { refresh: true } } * @prop onError Side effect function to be executed upon failure, e.g. { onError: error => notify(error.message) } * * @returns The current request state. Destructure as { data, error, isLoading, refetch }. * * @example * * import { useGetOne } from 'react-admin'; * * const UserProfile = ({ record }) => { * const { data, isLoading, error } = useGetOne('users', { id: record.id }); * if (isLoading) { return ; } * if (error) { return

ERROR

; } * return
User {data.username}
; * }; */ export declare const useGetOne: (resource: string, { id, meta }: GetOneParams, options?: UseQueryOptions) => UseGetOneHookValue; export declare type UseGetOneHookValue = UseQueryResult; //# sourceMappingURL=useGetOne.d.ts.map