@tanstack/query-core 4.13.0 → 4.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/queryObserver.esm.js +1 -2
- package/build/lib/queryObserver.esm.js.map +1 -1
- package/build/lib/queryObserver.js +1 -2
- package/build/lib/queryObserver.js.map +1 -1
- package/build/lib/queryObserver.mjs +1 -2
- package/build/lib/queryObserver.mjs.map +1 -1
- package/build/umd/index.development.js +1 -2
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/queryObserver.ts +1 -6
- package/src/tests/queryObserver.test.tsx +18 -0
package/package.json
CHANGED
package/src/queryObserver.ts
CHANGED
|
@@ -517,11 +517,6 @@ export class QueryObserver<
|
|
|
517
517
|
if (options.select && typeof placeholderData !== 'undefined') {
|
|
518
518
|
try {
|
|
519
519
|
placeholderData = options.select(placeholderData)
|
|
520
|
-
placeholderData = replaceData(
|
|
521
|
-
prevResult?.data,
|
|
522
|
-
placeholderData,
|
|
523
|
-
options,
|
|
524
|
-
)
|
|
525
520
|
this.selectError = null
|
|
526
521
|
} catch (selectError) {
|
|
527
522
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -534,7 +529,7 @@ export class QueryObserver<
|
|
|
534
529
|
|
|
535
530
|
if (typeof placeholderData !== 'undefined') {
|
|
536
531
|
status = 'success'
|
|
537
|
-
data = placeholderData as TData
|
|
532
|
+
data = replaceData(prevResult?.data, placeholderData, options) as TData
|
|
538
533
|
isPlaceholderData = true
|
|
539
534
|
}
|
|
540
535
|
}
|
|
@@ -505,6 +505,24 @@ describe('queryObserver', () => {
|
|
|
505
505
|
expect(results[1]).toMatchObject({ status: 'success', data: 'data' })
|
|
506
506
|
})
|
|
507
507
|
|
|
508
|
+
test('should structurally share placeholder data', async () => {
|
|
509
|
+
const key = queryKey()
|
|
510
|
+
const observer = new QueryObserver(queryClient, {
|
|
511
|
+
queryKey: key,
|
|
512
|
+
enabled: false,
|
|
513
|
+
queryFn: () => 'data',
|
|
514
|
+
placeholderData: {},
|
|
515
|
+
})
|
|
516
|
+
|
|
517
|
+
const firstData = observer.getCurrentResult().data
|
|
518
|
+
|
|
519
|
+
observer.setOptions({ placeholderData: {} })
|
|
520
|
+
|
|
521
|
+
const secondData = observer.getCurrentResult().data
|
|
522
|
+
|
|
523
|
+
expect(firstData).toBe(secondData)
|
|
524
|
+
})
|
|
525
|
+
|
|
508
526
|
test('the retrier should not throw an error when reject if the retrier is already resolved', async () => {
|
|
509
527
|
const key = queryKey()
|
|
510
528
|
let count = 0
|