Skip to content

Commit 5c8252e

Browse files
committed
Avoid duplicated copy
1 parent 22af0e8 commit 5c8252e

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

lib/OnyxCache.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,7 @@ class OnyxCache {
471471
return undefined;
472472
}
473473

474-
// Return a shallow copy to ensure React detects changes when items are added/removed
475-
return {...cachedCollection};
474+
return cachedCollection;
476475
}
477476
}
478477

lib/OnyxUtils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,8 @@ function tryGetCachedValue<TKey extends OnyxKey>(key: TKey): OnyxValue<OnyxKey>
530530
if (isCollectionKey(key)) {
531531
const collectionData = cache.getCollectionData(key);
532532
if (collectionData !== undefined) {
533-
val = collectionData;
533+
// Return a shallow copy to ensure React detects changes when items are added/removed
534+
val = {...collectionData};
534535
} else {
535536
// If we haven't loaded all keys yet, we can't determine if the collection exists
536537
if (cache.getAllKeys().size === 0) {

0 commit comments

Comments
 (0)