UNPKG

@react-native-async-storage/async-storage

Version:

Asynchronous, persistent, key-value storage system for React Native.

14 lines (12 loc) 485 B
import AsyncStorage from './AsyncStorage'; import type { AsyncStorageHook } from './types'; 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) ?? Promise.reject('Not implemented'), removeItem: (...args) => AsyncStorage.removeItem(key, ...args), }; }