import type { DependencyList } from 'react'; import type { OnyxKey, OnyxValue } from './types'; type UseOnyxSelector> = (data: OnyxValue | undefined) => TReturnValue; type UseOnyxOptions = { /** * 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; /** * 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; sourceValue?: NonNullable | undefined; }; type UseOnyxResult = [NonNullable | undefined, ResultMetadata]; declare function useOnyx>(key: TKey, options?: UseOnyxOptions, dependencies?: DependencyList): UseOnyxResult; export default useOnyx; export type { FetchStatus, ResultMetadata, UseOnyxResult, UseOnyxOptions, UseOnyxSelector };