We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 1ae6fa8 + 0198282 commit bf936b9Copy full SHA for bf936b9
src/hooks.ts
@@ -1,11 +1,14 @@
1
+import { useMemo } from 'react';
2
import AsyncStorage from './AsyncStorage';
3
import type { AsyncStorageHook } from './types';
4
5
export function useAsyncStorage(key: string): AsyncStorageHook {
- return {
6
+ const asyncStorage = useMemo(() => ({
7
getItem: (...args) => AsyncStorage.getItem(key, ...args),
8
setItem: (...args) => AsyncStorage.setItem(key, ...args),
9
mergeItem: (...args) => AsyncStorage.mergeItem(key, ...args),
10
removeItem: (...args) => AsyncStorage.removeItem(key, ...args),
- };
11
+ }), [key]);
12
+
13
+ return asyncStorage;
14
}
0 commit comments