Skip to content

Commit bf936b9

Browse files
author
Daomtthuan
authored
Merge pull request #1 from daomtthuan/patch-1
Update hooks.ts
2 parents 1ae6fa8 + 0198282 commit bf936b9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/hooks.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
import { useMemo } from 'react';
12
import AsyncStorage from './AsyncStorage';
23
import type { AsyncStorageHook } from './types';
34

45
export function useAsyncStorage(key: string): AsyncStorageHook {
5-
return {
6+
const asyncStorage = useMemo(() => ({
67
getItem: (...args) => AsyncStorage.getItem(key, ...args),
78
setItem: (...args) => AsyncStorage.setItem(key, ...args),
89
mergeItem: (...args) => AsyncStorage.mergeItem(key, ...args),
910
removeItem: (...args) => AsyncStorage.removeItem(key, ...args),
10-
};
11+
}), [key]);
12+
13+
return asyncStorage;
1114
}

0 commit comments

Comments
 (0)