diff --git a/lib/OnyxCache.ts b/lib/OnyxCache.ts index 6c88d168..071cbd9c 100644 --- a/lib/OnyxCache.ts +++ b/lib/OnyxCache.ts @@ -471,8 +471,7 @@ class OnyxCache { return undefined; } - // Return a shallow copy to ensure React detects changes when items are added/removed - return {...cachedCollection}; + return cachedCollection; } } diff --git a/lib/OnyxUtils.ts b/lib/OnyxUtils.ts index 39e8afd0..a0fad3f0 100644 --- a/lib/OnyxUtils.ts +++ b/lib/OnyxUtils.ts @@ -530,7 +530,8 @@ function tryGetCachedValue(key: TKey): OnyxValue if (isCollectionKey(key)) { const collectionData = cache.getCollectionData(key); if (collectionData !== undefined) { - val = collectionData; + // Return a shallow copy to ensure React detects changes when items are added/removed + val = {...collectionData}; } else { // If we haven't loaded all keys yet, we can't determine if the collection exists if (cache.getAllKeys().size === 0) {