Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/query-core/src/__tests__/utils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,20 @@ describe('core/utils', () => {

expect(current).toBe(next)
})

it('should return the previous value when both values are an array of undefined', () => {
const current = [undefined]
const next = replaceEqualDeep(current, [undefined])

expect(next).toBe(current)
})

it('should return the previous value when both values are an array that contains undefined', () => {
const current = [{ foo: 1 }, undefined]
const next = replaceEqualDeep(current, [{ foo: 1 }, undefined])

expect(next).toBe(current)
})
})

describe('matchMutation', () => {
Expand Down
5 changes: 2 additions & 3 deletions packages/query-core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,9 @@ export function replaceEqualDeep(a: any, b: any): any {
for (let i = 0; i < bSize; i++) {
const key = array ? i : bItems[i]
if (
!array &&
((!array && aItems.includes(key)) || array) &&
a[key] === undefined &&
b[key] === undefined &&
aItems.includes(key)
b[key] === undefined
) {
copy[key] = undefined
equalItems++
Expand Down