mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 22:11:24 -05:00
Fix: Memoize cache hook return objects
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { useRef, useCallback } from 'react';
|
import { useRef, useCallback, useMemo } from 'react';
|
||||||
import { supabase } from '@/integrations/supabase/client';
|
import { supabase } from '@/integrations/supabase/client';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -221,7 +221,7 @@ export function useEntityCache() {
|
|||||||
*/
|
*/
|
||||||
const getCacheRef = useCallback(() => cacheRef.current, []);
|
const getCacheRef = useCallback(() => cacheRef.current, []);
|
||||||
|
|
||||||
return {
|
return useMemo(() => ({
|
||||||
getCached,
|
getCached,
|
||||||
has,
|
has,
|
||||||
setCached,
|
setCached,
|
||||||
@@ -233,5 +233,17 @@ export function useEntityCache() {
|
|||||||
getSize,
|
getSize,
|
||||||
getTotalSize,
|
getTotalSize,
|
||||||
getCacheRef,
|
getCacheRef,
|
||||||
};
|
}), [
|
||||||
|
getCached,
|
||||||
|
has,
|
||||||
|
setCached,
|
||||||
|
getUncachedIds,
|
||||||
|
bulkFetch,
|
||||||
|
fetchRelatedEntities,
|
||||||
|
clear,
|
||||||
|
clearAll,
|
||||||
|
getSize,
|
||||||
|
getTotalSize,
|
||||||
|
getCacheRef,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useRef, useCallback } from 'react';
|
import { useRef, useCallback, useMemo } from 'react';
|
||||||
import { supabase } from '@/integrations/supabase/client';
|
import { supabase } from '@/integrations/supabase/client';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -181,7 +181,7 @@ export function useProfileCache() {
|
|||||||
*/
|
*/
|
||||||
const getCacheRef = useCallback(() => cacheRef.current, []);
|
const getCacheRef = useCallback(() => cacheRef.current, []);
|
||||||
|
|
||||||
return {
|
return useMemo(() => ({
|
||||||
getCached,
|
getCached,
|
||||||
has,
|
has,
|
||||||
setCached,
|
setCached,
|
||||||
@@ -195,5 +195,19 @@ export function useProfileCache() {
|
|||||||
getSize,
|
getSize,
|
||||||
getAllCachedIds,
|
getAllCachedIds,
|
||||||
getCacheRef,
|
getCacheRef,
|
||||||
};
|
}), [
|
||||||
|
getCached,
|
||||||
|
has,
|
||||||
|
setCached,
|
||||||
|
getUncachedIds,
|
||||||
|
bulkFetch,
|
||||||
|
fetchAsMap,
|
||||||
|
fetchForSubmissions,
|
||||||
|
getDisplayName,
|
||||||
|
invalidate,
|
||||||
|
clear,
|
||||||
|
getSize,
|
||||||
|
getAllCachedIds,
|
||||||
|
getCacheRef,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user