Skip to content

Commit

Permalink
TW-1127 Use useDidUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
keshan3262 committed Oct 27, 2023
1 parent b7f4339 commit 1e7fcfb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib/temple/front/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import browser, { Storage } from 'webextension-polyfill';

import { fetchFromStorage, putToStorage } from 'lib/storage';
import { useRetryableSWR } from 'lib/swr';
import { useDidUpdate } from 'lib/ui/hooks';

export function useStorage<T = any>(key: string): [T | null | undefined, (val: SetStateAction<T>) => Promise<void>];
export function useStorage<T = any>(key: string, fallback: T): [T, (val: SetStateAction<T>) => Promise<void>];
Expand Down Expand Up @@ -43,7 +44,7 @@ export function usePassiveStorage<T = any>(key: string, fallback?: T) {

const [value, setValue] = useState(finalData);

useEffect(() => {
useDidUpdate(() => {
setValue(finalData);
}, [finalData]);

Expand Down

0 comments on commit 1e7fcfb

Please sign in to comment.