Skip to content

Commit ed722d2

Browse files
committed
Fix array corruption in profile enrichment setQueryData
The spread operator {...data} converts arrays into plain objects ({0: item, 1: item, ...}) which breaks .map() calls on query data like pinnedFeedInfos. Use Array.isArray check to preserve arrays when creating new references for React Query cache updates.
1 parent b971c7e commit ed722d2

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/state/queries/profile-enrichment.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,13 @@ function applyEnrichment(
121121
0,
122122
)
123123
if (mutated) {
124-
// Suppress our own subscriber from re-scanning this update
124+
// Suppress our own subscriber from re-scanning this update.
125+
// Must preserve data type: arrays stay arrays, objects stay objects.
125126
isApplyingEnrichment = true
126-
queryClient.setQueryData(query.queryKey, {...(data as any)})
127+
queryClient.setQueryData(
128+
query.queryKey,
129+
Array.isArray(data) ? [...data] : {...(data as any)},
130+
)
127131
isApplyingEnrichment = false
128132
}
129133
}

0 commit comments

Comments
 (0)