From a72f9be38c0bdbdd84c492b20e09d8f475890cb3 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Tue, 9 Feb 2021 15:38:13 +0100 Subject: [PATCH] Don't re-read storage on useFavorites (#4639) --- packages/react-hooks/src/useFavorites.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-hooks/src/useFavorites.ts b/packages/react-hooks/src/useFavorites.ts index cf82f26f0c..d4f4147e2a 100644 --- a/packages/react-hooks/src/useFavorites.ts +++ b/packages/react-hooks/src/useFavorites.ts @@ -8,7 +8,7 @@ import { useCacheKey } from './useCacheKey'; // hook for favorites with local storage export function useFavorites (storageKeyBase: string): [string[], (address: string) => void] { const [getCache, setCache] = useCacheKey(storageKeyBase); - const [favorites, setFavorites] = useState(getCache() || []); + const [favorites, setFavorites] = useState(() => getCache() || []); const toggleFavorite = useCallback( (address: string): void => setFavorites(