/** * @format */ import AsyncStorage from './AsyncStorage'; type AsyncStorageHook = { getItem: ( callback?: ?(error: ?Error, result: string | null) => void, ) => Promise, setItem: ( value: string, callback?: ?(error: ?Error) => void, ) => Promise, mergeItem: ( value: string, callback?: ?(error: ?Error) => void, ) => Promise, removeItem: (callback?: ?(error: ?Error) => void) => Promise, }; export function useAsyncStorage(key: string): AsyncStorageHook { return { getItem: (...args) => AsyncStorage.getItem(key, ...args), setItem: (...args) => AsyncStorage.setItem(key, ...args), mergeItem: (...args) => AsyncStorage.mergeItem(key, ...args), removeItem: (...args) => AsyncStorage.removeItem(key, ...args), }; }