import type { DependencyList } from 'react'; import type { OnyxKey, OnyxValue } from './types'; type BaseUseOnyxOptions = { /** * Determines if this key in this subscription is safe to be evicted. */ canEvict?: boolean; /** * If set to `false`, then no data will be prefilled into the component. */ initWithStoredValues?: boolean; /** * If set to `true`, data will be retrieved from cache during the first render even if there is a pending merge for the key. */ allowStaleData?: boolean; /** * If set to `false`, the connection won't be reused between other subscribers that are listening to the same Onyx key * with the same connect configurations. */ reuseConnection?: boolean; }; type UseOnyxInitialValueOption = { /** * This value will be returned by the hook on the first render while the data is being read from Onyx. */ initialValue?: TInitialValue; }; type UseOnyxSelector> = (data: OnyxValue | undefined) => TReturnValue; type UseOnyxSelectorOption = { /** * This will be used to subscribe to a subset of an Onyx key's data. * Using this setting on `useOnyx` can have very positive performance benefits because the component will only re-render * when the subset of data changes. Otherwise, any change of data on any property would normally * cause the component to re-render (and that can be expensive from a performance standpoint). * @see `useOnyx` cannot return `null` and so selector will replace `null` with `undefined` to maintain compatibility. */ selector?: UseOnyxSelector; }; type FetchStatus = 'loading' | 'loaded'; type ResultMetadata = { status: FetchStatus; }; type UseOnyxResult = [NonNullable | undefined, ResultMetadata]; declare function useOnyx>(key: TKey, options?: BaseUseOnyxOptions & UseOnyxInitialValueOption & Required>, dependencies?: DependencyList): UseOnyxResult; declare function useOnyx>(key: TKey, options?: BaseUseOnyxOptions & UseOnyxInitialValueOption>, dependencies?: DependencyList): UseOnyxResult; export default useOnyx; export type { FetchStatus, ResultMetadata, UseOnyxResult };