Skip to content

Commit 32a55ad

Browse files
committed
refactor(query-core): use shallowEqualObjects for result comparison
1 parent e5a60aa commit 32a55ad

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

packages/query-core/src/queriesObserver.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { notifyManager } from './notifyManager'
22
import { QueryObserver } from './queryObserver'
33
import { Subscribable } from './subscribable'
4-
import { replaceEqualDeep } from './utils'
4+
import { replaceEqualDeep, shallowEqualObjects } from './utils'
55
import type {
66
DefaultedQueryObserverOptions,
77
QueryObserverOptions,
@@ -123,17 +123,12 @@ export class QueriesObserver<
123123
)
124124

125125
if (prevObservers.length === newObservers.length && !hasIndexChange) {
126-
const resultChanged = newResult.some((result, index) => {
126+
const hasResultChangeOnly = newResult.some((result, index) => {
127127
const prev = this.#result[index]
128-
return (
129-
!prev ||
130-
result.data !== prev.data ||
131-
result.isPending !== prev.isPending ||
132-
result.error !== prev.error
133-
)
128+
return !prev || !shallowEqualObjects(result, prev)
134129
})
135130

136-
if (resultChanged) {
131+
if (hasResultChangeOnly) {
137132
this.#result = newResult
138133
this.#notify()
139134
}

0 commit comments

Comments
 (0)