Don't re-read storage on useFavorites (#4639)
This commit is contained in:
parent
f14156a3c0
commit
a72f9be38c
@ -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<string[]>(storageKeyBase);
|
||||
const [favorites, setFavorites] = useState<string[]>(getCache() || []);
|
||||
const [favorites, setFavorites] = useState<string[]>(() => getCache() || []);
|
||||
|
||||
const toggleFavorite = useCallback(
|
||||
(address: string): void => setFavorites(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user