@tanstack/react-query 5.0.0-alpha.26 → 5.0.0-alpha.31
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/HydrationBoundary.d.ts.map +1 -0
- package/build/lib/QueryClientProvider.d.ts.map +1 -0
- package/build/lib/QueryErrorResetBoundary.d.ts.map +1 -0
- package/build/lib/__tests__/HydrationBoundary.test.d.ts.map +1 -0
- package/build/lib/__tests__/QueryClientProvider.test.d.ts.map +1 -0
- package/build/lib/__tests__/QueryResetErrorBoundary.test.d.ts.map +1 -0
- package/build/lib/__tests__/ssr-hydration.test.d.ts.map +1 -0
- package/build/lib/__tests__/ssr.test.d.ts.map +1 -0
- package/build/lib/__tests__/suspense.test.d.ts.map +1 -0
- package/build/lib/__tests__/useInfiniteQuery.test.d.ts.map +1 -0
- package/build/lib/__tests__/useInfiniteQuery.type.test.d.ts.map +1 -0
- package/build/lib/__tests__/useIsFetching.test.d.ts.map +1 -0
- package/build/lib/__tests__/useMutation.test.d.ts.map +1 -0
- package/build/lib/__tests__/useMutationState.test.d.ts.map +1 -0
- package/build/lib/__tests__/useQueries.test.d.ts.map +1 -0
- package/build/lib/__tests__/useQuery.test.d.ts.map +1 -0
- package/build/lib/__tests__/useQuery.types.test.d.ts.map +1 -0
- package/build/lib/__tests__/utils.d.ts.map +1 -0
- package/build/lib/errorBoundaryUtils.d.ts.map +1 -0
- package/build/lib/index.d.ts.map +1 -0
- package/build/lib/isRestoring.d.ts.map +1 -0
- package/build/lib/suspense.d.ts.map +1 -0
- package/build/lib/types.d.ts.map +1 -0
- package/build/lib/useBaseQuery.d.ts.map +1 -0
- package/build/lib/useInfiniteQuery.d.ts.map +1 -0
- package/build/lib/useIsFetching.d.ts.map +1 -0
- package/build/lib/useMutation.d.ts.map +1 -0
- package/build/lib/useMutationState.d.ts.map +1 -0
- package/build/lib/useQueries.d.ts.map +1 -0
- package/build/lib/useQuery.d.ts.map +1 -0
- package/build/lib/utils.d.ts.map +1 -0
- package/build/umd/index.development.js +5 -5
- 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 +2 -2
- package/src/__tests__/useQuery.test.tsx +54 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-query",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.31",
|
|
4
4
|
"description": "Hooks for managing, caching and syncing asynchronous and remote data in React",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"react-error-boundary": "^3.1.4"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@tanstack/query-core": "5.0.0-alpha.
|
|
42
|
+
"@tanstack/query-core": "5.0.0-alpha.31"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": "^18.0.0",
|
|
@@ -1542,6 +1542,60 @@ describe('useQuery', () => {
|
|
|
1542
1542
|
})
|
|
1543
1543
|
})
|
|
1544
1544
|
|
|
1545
|
+
it('should keep the previous queryKey (from prevQuery) between multiple pending queries when placeholderData is set and select fn transform is used', async () => {
|
|
1546
|
+
const keys: Array<readonly unknown[] | null> = []
|
|
1547
|
+
const key = queryKey()
|
|
1548
|
+
const states: UseQueryResult<number>[] = []
|
|
1549
|
+
|
|
1550
|
+
function Page() {
|
|
1551
|
+
const [count, setCount] = React.useState(0)
|
|
1552
|
+
|
|
1553
|
+
const state = useQuery({
|
|
1554
|
+
queryKey: [key, count],
|
|
1555
|
+
queryFn: async () => {
|
|
1556
|
+
await sleep(10)
|
|
1557
|
+
return {
|
|
1558
|
+
count,
|
|
1559
|
+
}
|
|
1560
|
+
},
|
|
1561
|
+
select(data) {
|
|
1562
|
+
return data.count
|
|
1563
|
+
},
|
|
1564
|
+
placeholderData: (prevData, prevQuery) => {
|
|
1565
|
+
if (prevQuery) {
|
|
1566
|
+
keys.push(prevQuery.queryKey)
|
|
1567
|
+
}
|
|
1568
|
+
return prevData
|
|
1569
|
+
},
|
|
1570
|
+
})
|
|
1571
|
+
|
|
1572
|
+
states.push(state)
|
|
1573
|
+
|
|
1574
|
+
return (
|
|
1575
|
+
<div>
|
|
1576
|
+
<div>data: {state.data}</div>
|
|
1577
|
+
<button onClick={() => setCount((prev) => prev + 1)}>setCount</button>
|
|
1578
|
+
</div>
|
|
1579
|
+
)
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
const rendered = renderWithClient(queryClient, <Page />)
|
|
1583
|
+
|
|
1584
|
+
await waitFor(() => rendered.getByText('data: 0'))
|
|
1585
|
+
|
|
1586
|
+
fireEvent.click(rendered.getByRole('button', { name: 'setCount' }))
|
|
1587
|
+
fireEvent.click(rendered.getByRole('button', { name: 'setCount' }))
|
|
1588
|
+
fireEvent.click(rendered.getByRole('button', { name: 'setCount' }))
|
|
1589
|
+
|
|
1590
|
+
await waitFor(() => rendered.getByText('data: 3'))
|
|
1591
|
+
|
|
1592
|
+
const allPreviousKeysAreTheFirstQueryKey = keys.every(
|
|
1593
|
+
(k) => JSON.stringify(k) === JSON.stringify([key, 0]),
|
|
1594
|
+
)
|
|
1595
|
+
|
|
1596
|
+
expect(allPreviousKeysAreTheFirstQueryKey).toBe(true)
|
|
1597
|
+
})
|
|
1598
|
+
|
|
1545
1599
|
it('should show placeholderData between multiple pending queries when select fn transform is used', async () => {
|
|
1546
1600
|
const key = queryKey()
|
|
1547
1601
|
const states: UseQueryResult<number>[] = []
|