Skip to content

Commit 95bed80

Browse files
committed
feat(queryClient): add setQueriesData utility
wrap setQueriesData in notifyManager.batch to avoid unnecessary re-renders
1 parent 0321539 commit 95bed80

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/core/queryClient.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,14 @@ export class QueryClient {
140140
updater: Updater<TData | undefined, TData>,
141141
options?: SetDataOptions
142142
): [QueryKey, TData][] {
143-
return this.getQueryCache()
144-
.findAll(queryKeyOrFilters)
145-
.map(({ queryKey }) => [
146-
queryKey,
147-
this.setQueryData<TData>(queryKey, updater, options),
148-
])
143+
return notifyManager.batch(() =>
144+
this.getQueryCache()
145+
.findAll(queryKeyOrFilters)
146+
.map(({ queryKey }) => [
147+
queryKey,
148+
this.setQueryData<TData>(queryKey, updater, options),
149+
])
150+
)
149151
}
150152

151153
getQueryState<TData = unknown, TError = undefined>(

0 commit comments

Comments
 (0)