Skip to content

Commit ae10094

Browse files
authored
fixed(queryObserver): fetch data twice when mounted (#1320)
* Only work once when forceFetchOnMount is ture or refetchOnMount is 'always' * fixed(queryObserver): fetch data twice when mounted * optimization(query): reduce unnecessary recursion
1 parent f52953c commit ae10094

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/core/query.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,12 @@ export class Query<TResult, TError> {
197197
// Get the new data
198198
let data: TResult | undefined = functionalUpdate(updater, prevData)
199199

200-
// Structurally share data between prev and new data if needed
201-
if (this.config.structuralSharing) {
202-
data = replaceEqualDeep(prevData, data)
203-
}
204-
205200
// Use prev data if an isDataEqual function is defined and returns `true`
206201
if (this.config.isDataEqual?.(prevData, data)) {
207202
data = prevData
203+
} else if (this.config.structuralSharing) {
204+
// Structurally share data between prev and new data if needed
205+
data = replaceEqualDeep(prevData, data)
208206
}
209207

210208
// Try to determine if more data can be fetched

0 commit comments

Comments
 (0)