import { Identifier, Record, UseDataProviderOptions } from '../types';
import { Refetch } from './useQueryWithStore';
/**
* 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: { loading: true, loaded: false, refetch }
* - success: { data: [data from response], loading: false, loaded: true, refetch }
* - error: { error: [error from response], loading: false, loaded: 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 id The resource identifier, e.g. 123
* @param {Object} options Options object to pass to the dataProvider.
* @param {boolean} options.enabled Flag to conditionally run the query. If it's false, the query will not run
* @param {Function} options.onSuccess Side effect function to be executed upon success, e.g. { onSuccess: { refresh: true } }
* @param {Function} options.onFailure Side effect function to be executed upon failure, e.g. { onFailure: error => notify(error.message) }
*
* @returns The current request state. Destructure as { data, error, loading, loaded, refetch }.
*
* @example
*
* import { useGetOne } from '../app';
*
* const UserProfile = ({ record }) => {
* const { data, loading, error } = useGetOne('users', record.id);
* if (loading) { return
ERROR
; } * return