Fix: Memoize cache hook return objects

This commit is contained in:
gpt-engineer-app[bot]
2025-10-13 20:14:56 +00:00
parent c4612df6a5
commit 3aa928da00
2 changed files with 32 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
import { useRef, useCallback } from 'react';
import { useRef, useCallback, useMemo } from 'react';
import { supabase } from '@/integrations/supabase/client';
/**
@@ -221,7 +221,7 @@ export function useEntityCache() {
*/
const getCacheRef = useCallback(() => cacheRef.current, []);
return {
return useMemo(() => ({
getCached,
has,
setCached,
@@ -233,5 +233,17 @@ export function useEntityCache() {
getSize,
getTotalSize,
getCacheRef,
};
}), [
getCached,
has,
setCached,
getUncachedIds,
bulkFetch,
fetchRelatedEntities,
clear,
clearAll,
getSize,
getTotalSize,
getCacheRef,
]);
}

View File

@@ -1,4 +1,4 @@
import { useRef, useCallback } from 'react';
import { useRef, useCallback, useMemo } from 'react';
import { supabase } from '@/integrations/supabase/client';
/**
@@ -181,7 +181,7 @@ export function useProfileCache() {
*/
const getCacheRef = useCallback(() => cacheRef.current, []);
return {
return useMemo(() => ({
getCached,
has,
setCached,
@@ -195,5 +195,19 @@ export function useProfileCache() {
getSize,
getAllCachedIds,
getCacheRef,
};
}), [
getCached,
has,
setCached,
getUncachedIds,
bulkFetch,
fetchAsMap,
fetchForSubmissions,
getDisplayName,
invalidate,
clear,
getSize,
getAllCachedIds,
getCacheRef,
]);
}