Skip to content
Source
Sign inSign up
TanStack/query

fix(solid-query): avoid redundant reconciliation 🤖🤖🤖 #11255

Closedngocdevv(GitHub profile, opens in a new tab)wants to merge 7 commits intomain fromrefs/pull/11255/headopened View on GitHub

Showing 3 changed files with 104 additions and 3 deletions.

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/calm-wolves-reconcile.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/solid-query': patch
+---
+​
+Avoid calling custom reconciliation when query data is missing or unchanged.
75 additions and 0 deletionspackages/solid-query/src/__tests__/useQuery.test.tsxModified
View file
@@ -929,6 +929,81 @@
return null
​
+ it('should only reconcile when observer data changes', async () => {
+ const key = queryKey()
+ const firstData = { count: 1 }
+ const secondData = { count: 2 }
+ const thirdData = { count: 3 }
+ const queryResults = [firstData, secondData, secondData, thirdData]
+ const reconciliationInputs: Array<[number | undefined, number]> = []
+ let fetchCount = 0
+ const reconcileData = vi.fn(
+ (oldData: { count: number } | undefined, newData: { count: number }) => {
+ reconciliationInputs.push([oldData?.count, newData.count])
+ return reconcile(newData)(oldData)
+ },
+ )
+​
+ function Page() {
+ const state = useQuery(() => ({
+ queryKey: key,