@tanstack/react-query 4.29.23 → 4.29.25

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.
Files changed (89) hide show
  1. package/build/lib/Hydrate.d.ts.map +1 -1
  2. package/build/lib/Hydrate.esm.js.map +1 -1
  3. package/build/lib/Hydrate.js.map +1 -1
  4. package/build/lib/Hydrate.mjs.map +1 -1
  5. package/build/lib/__tests__/utils.d.ts +1 -1
  6. package/build/lib/__tests__/utils.d.ts.map +1 -1
  7. package/build/lib/errorBoundaryUtils.d.ts.map +1 -1
  8. package/build/lib/errorBoundaryUtils.esm.js.map +1 -1
  9. package/build/lib/errorBoundaryUtils.js.map +1 -1
  10. package/build/lib/errorBoundaryUtils.mjs.map +1 -1
  11. package/build/lib/reactBatchedUpdates.d.ts.map +1 -1
  12. package/build/lib/reactBatchedUpdates.esm.js.map +1 -1
  13. package/build/lib/reactBatchedUpdates.js.map +1 -1
  14. package/build/lib/reactBatchedUpdates.mjs.map +1 -1
  15. package/build/lib/reactBatchedUpdates.native.d.ts.map +1 -1
  16. package/build/lib/types.d.ts +1 -1
  17. package/build/lib/types.d.ts.map +1 -1
  18. package/build/lib/useBaseQuery.d.ts.map +1 -1
  19. package/build/lib/useBaseQuery.esm.js +1 -1
  20. package/build/lib/useBaseQuery.esm.js.map +1 -1
  21. package/build/lib/useBaseQuery.js +1 -1
  22. package/build/lib/useBaseQuery.js.map +1 -1
  23. package/build/lib/useBaseQuery.mjs +1 -1
  24. package/build/lib/useBaseQuery.mjs.map +1 -1
  25. package/build/lib/useInfiniteQuery.d.ts.map +1 -1
  26. package/build/lib/useInfiniteQuery.esm.js.map +1 -1
  27. package/build/lib/useInfiniteQuery.js.map +1 -1
  28. package/build/lib/useInfiniteQuery.mjs.map +1 -1
  29. package/build/lib/useIsFetching.d.ts +1 -1
  30. package/build/lib/useIsFetching.d.ts.map +1 -1
  31. package/build/lib/useIsFetching.esm.js.map +1 -1
  32. package/build/lib/useIsFetching.js.map +1 -1
  33. package/build/lib/useIsFetching.mjs.map +1 -1
  34. package/build/lib/useIsMutating.d.ts +1 -1
  35. package/build/lib/useIsMutating.d.ts.map +1 -1
  36. package/build/lib/useIsMutating.esm.js +1 -1
  37. package/build/lib/useIsMutating.esm.js.map +1 -1
  38. package/build/lib/useIsMutating.js +1 -1
  39. package/build/lib/useIsMutating.js.map +1 -1
  40. package/build/lib/useIsMutating.mjs +1 -1
  41. package/build/lib/useIsMutating.mjs.map +1 -1
  42. package/build/lib/useMutation.d.ts.map +1 -1
  43. package/build/lib/useMutation.esm.js +1 -1
  44. package/build/lib/useMutation.esm.js.map +1 -1
  45. package/build/lib/useMutation.js +1 -1
  46. package/build/lib/useMutation.js.map +1 -1
  47. package/build/lib/useMutation.mjs +1 -1
  48. package/build/lib/useMutation.mjs.map +1 -1
  49. package/build/lib/useQueries.d.ts +1 -1
  50. package/build/lib/useQueries.d.ts.map +1 -1
  51. package/build/lib/useQueries.esm.js +1 -3
  52. package/build/lib/useQueries.esm.js.map +1 -1
  53. package/build/lib/useQueries.js +1 -3
  54. package/build/lib/useQueries.js.map +1 -1
  55. package/build/lib/useQueries.mjs +1 -3
  56. package/build/lib/useQueries.mjs.map +1 -1
  57. package/build/lib/useQuery.d.ts.map +1 -1
  58. package/build/lib/useQuery.esm.js.map +1 -1
  59. package/build/lib/useQuery.js.map +1 -1
  60. package/build/lib/useQuery.mjs.map +1 -1
  61. package/build/umd/index.development.js +0 -2
  62. package/build/umd/index.development.js.map +1 -1
  63. package/build/umd/index.production.js.map +1 -1
  64. package/package.json +2 -2
  65. package/src/Hydrate.tsx +1 -1
  66. package/src/__tests__/Hydrate.test.tsx +4 -4
  67. package/src/__tests__/QueryClientProvider.test.tsx +2 -2
  68. package/src/__tests__/QueryResetErrorBoundary.test.tsx +1 -1
  69. package/src/__tests__/ssr-hydration.test.tsx +2 -2
  70. package/src/__tests__/ssr.test.tsx +2 -2
  71. package/src/__tests__/suspense.test.tsx +1 -1
  72. package/src/__tests__/useInfiniteQuery.test.tsx +1 -1
  73. package/src/__tests__/useIsFetching.test.tsx +1 -1
  74. package/src/__tests__/useIsMutating.test.tsx +3 -3
  75. package/src/__tests__/useMutation.test.tsx +2 -2
  76. package/src/__tests__/useQueries.test.tsx +1 -1
  77. package/src/__tests__/useQuery.test.tsx +2 -2
  78. package/src/__tests__/utils.tsx +2 -2
  79. package/src/errorBoundaryUtils.ts +2 -2
  80. package/src/reactBatchedUpdates.native.ts +1 -0
  81. package/src/reactBatchedUpdates.ts +1 -0
  82. package/src/types.ts +4 -4
  83. package/src/useBaseQuery.ts +4 -4
  84. package/src/useInfiniteQuery.ts +3 -3
  85. package/src/useIsFetching.ts +2 -2
  86. package/src/useIsMutating.ts +3 -3
  87. package/src/useMutation.ts +5 -5
  88. package/src/useQueries.ts +5 -5
  89. package/src/useQuery.ts +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-query",
3
- "version": "4.29.23",
3
+ "version": "4.29.25",
4
4
  "description": "Hooks for managing, caching and syncing asynchronous and remote data in React",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "use-sync-external-store": "^1.2.0",
50
- "@tanstack/query-core": "4.29.23"
50
+ "@tanstack/query-core": "4.29.25"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
package/src/Hydrate.tsx CHANGED
@@ -1,9 +1,9 @@
1
1
  'use client'
2
2
  import * as React from 'react'
3
3
 
4
- import type { HydrateOptions } from '@tanstack/query-core'
5
4
  import { hydrate } from '@tanstack/query-core'
6
5
  import { useQueryClient } from './QueryClientProvider'
6
+ import type { HydrateOptions } from '@tanstack/query-core'
7
7
  import type { ContextOptions } from './types'
8
8
 
9
9
  export function useHydrate(
@@ -1,17 +1,17 @@
1
1
  import * as React from 'react'
2
2
  import { render } from '@testing-library/react'
3
3
 
4
+ import * as coreModule from '@tanstack/query-core'
4
5
  import {
6
+ Hydrate,
7
+ QueryCache,
5
8
  QueryClient,
6
9
  QueryClientProvider,
7
- QueryCache,
8
- useQuery,
9
10
  dehydrate,
10
11
  useHydrate,
11
- Hydrate,
12
+ useQuery,
12
13
  } from '@tanstack/react-query'
13
14
  import { createQueryClient, sleep } from './utils'
14
- import * as coreModule from '@tanstack/query-core'
15
15
 
16
16
  describe('React hydration', () => {
17
17
  const fetchData: (value: string) => Promise<string> = (value) =>
@@ -2,14 +2,14 @@ import * as React from 'react'
2
2
  import { render, waitFor } from '@testing-library/react'
3
3
  import { renderToString } from 'react-dom/server'
4
4
 
5
- import { sleep, queryKey, createQueryClient } from './utils'
6
5
  import {
6
+ QueryCache,
7
7
  QueryClient,
8
8
  QueryClientProvider,
9
- QueryCache,
10
9
  useQuery,
11
10
  useQueryClient,
12
11
  } from '..'
12
+ import { createQueryClient, queryKey, sleep } from './utils'
13
13
 
14
14
  describe('QueryClientProvider', () => {
15
15
  test('sets a specific cache for all queries to use', async () => {
@@ -2,8 +2,8 @@ import { fireEvent, waitFor } from '@testing-library/react'
2
2
  import { ErrorBoundary } from 'react-error-boundary'
3
3
  import * as React from 'react'
4
4
 
5
- import { createQueryClient, queryKey, renderWithClient, sleep } from './utils'
6
5
  import { QueryCache, QueryErrorResetBoundary, useQueries, useQuery } from '..'
6
+ import { createQueryClient, queryKey, renderWithClient, sleep } from './utils'
7
7
 
8
8
  // TODO: This should be removed with the types for react-error-boundary get updated.
9
9
  declare module 'react-error-boundary' {
@@ -6,11 +6,11 @@ import ReactDOMServer from 'react-dom/server'
6
6
  import type {} from 'react-dom/next'
7
7
 
8
8
  import {
9
- useQuery,
10
- QueryClientProvider,
11
9
  QueryCache,
10
+ QueryClientProvider,
12
11
  dehydrate,
13
12
  hydrate,
13
+ useQuery,
14
14
  } from '..'
15
15
  import { createQueryClient, setIsServer, sleep } from './utils'
16
16
 
@@ -6,8 +6,8 @@ import * as React from 'react'
6
6
  // @ts-ignore
7
7
  import { renderToString } from 'react-dom/server'
8
8
 
9
- import { sleep, queryKey, createQueryClient } from './utils'
10
- import { useQuery, QueryClientProvider, QueryCache, useInfiniteQuery } from '..'
9
+ import { QueryCache, QueryClientProvider, useInfiniteQuery, useQuery } from '..'
10
+ import { createQueryClient, queryKey, sleep } from './utils'
11
11
 
12
12
  describe('Server Side Rendering', () => {
13
13
  it('should not trigger fetch', () => {
@@ -1,7 +1,6 @@
1
1
  import { fireEvent, waitFor } from '@testing-library/react'
2
2
  import * as React from 'react'
3
3
  import { ErrorBoundary } from 'react-error-boundary'
4
- import type { UseInfiniteQueryResult, UseQueryResult } from '..'
5
4
  import {
6
5
  QueryCache,
7
6
  QueryErrorResetBoundary,
@@ -11,6 +10,7 @@ import {
11
10
  useQueryErrorResetBoundary,
12
11
  } from '..'
13
12
  import { createQueryClient, queryKey, renderWithClient, sleep } from './utils'
13
+ import type { UseInfiniteQueryResult, UseQueryResult } from '..'
14
14
 
15
15
  describe("useQuery's in Suspense mode", () => {
16
16
  const queryCache = new QueryCache()
@@ -1,6 +1,7 @@
1
1
  import { fireEvent, waitFor } from '@testing-library/react'
2
2
  import * as React from 'react'
3
3
 
4
+ import { QueryCache, useInfiniteQuery } from '..'
4
5
  import {
5
6
  createQueryClient,
6
7
  queryKey,
@@ -13,7 +14,6 @@ import type {
13
14
  QueryFunctionContext,
14
15
  UseInfiniteQueryResult,
15
16
  } from '..'
16
- import { QueryCache, useInfiniteQuery } from '..'
17
17
 
18
18
  interface Result {
19
19
  items: number[]
@@ -2,6 +2,7 @@ import { fireEvent, waitFor } from '@testing-library/react'
2
2
  import * as React from 'react'
3
3
  import { ErrorBoundary } from 'react-error-boundary'
4
4
 
5
+ import { QueryCache, useIsFetching, useQuery } from '..'
5
6
  import {
6
7
  createQueryClient,
7
8
  queryKey,
@@ -10,7 +11,6 @@ import {
10
11
  sleep,
11
12
  } from './utils'
12
13
  import type { QueryClient } from '..'
13
- import { QueryCache, useIsFetching, useQuery } from '..'
14
14
 
15
15
  describe('useIsFetching', () => {
16
16
  // See https://github.com/tannerlinsley/react-query/issues/105
@@ -1,16 +1,16 @@
1
1
  import { fireEvent, waitFor } from '@testing-library/react'
2
2
  import * as React from 'react'
3
+ import { ErrorBoundary } from 'react-error-boundary'
4
+ import { QueryClient } from '@tanstack/query-core'
3
5
  import { useIsMutating } from '../useIsMutating'
4
6
  import { useMutation } from '../useMutation'
7
+ import * as MutationCacheModule from '../../../query-core/src/mutationCache'
5
8
  import {
6
9
  createQueryClient,
7
10
  renderWithClient,
8
11
  setActTimeout,
9
12
  sleep,
10
13
  } from './utils'
11
- import { ErrorBoundary } from 'react-error-boundary'
12
- import { QueryClient } from '@tanstack/query-core'
13
- import * as MutationCacheModule from '../../../query-core/src/mutationCache'
14
14
 
15
15
  describe('useIsMutating', () => {
16
16
  it('should return the number of fetching mutations', async () => {
@@ -3,9 +3,7 @@ import '@testing-library/jest-dom'
3
3
  import * as React from 'react'
4
4
  import { ErrorBoundary } from 'react-error-boundary'
5
5
 
6
- import type { QueryClient } from '..'
7
6
  import { MutationCache, QueryCache, useMutation } from '..'
8
- import type { UseMutationResult } from '../types'
9
7
  import {
10
8
  createQueryClient,
11
9
  mockNavigatorOnLine,
@@ -14,6 +12,8 @@ import {
14
12
  setActTimeout,
15
13
  sleep,
16
14
  } from './utils'
15
+ import type { QueryClient } from '..'
16
+ import type { UseMutationResult } from '../types'
17
17
 
18
18
  describe('useMutation', () => {
19
19
  const queryCache = new QueryCache()
@@ -4,6 +4,7 @@ import { ErrorBoundary } from 'react-error-boundary'
4
4
 
5
5
  import * as QueriesObserverModule from '../../../query-core/src/queriesObserver'
6
6
 
7
+ import { QueriesObserver, QueryCache, useQueries } from '..'
7
8
  import {
8
9
  createQueryClient,
9
10
  expectType,
@@ -20,7 +21,6 @@ import type {
20
21
  UseQueryOptions,
21
22
  UseQueryResult,
22
23
  } from '..'
23
- import { QueriesObserver, QueryCache, useQueries } from '..'
24
24
  import type { QueryFunctionContext } from '@tanstack/query-core'
25
25
 
26
26
  describe('useQueries', () => {
@@ -1,6 +1,8 @@
1
1
  import { act, fireEvent, waitFor } from '@testing-library/react'
2
2
  import '@testing-library/jest-dom'
3
3
  import * as React from 'react'
4
+ import { ErrorBoundary } from 'react-error-boundary'
5
+ import { QueryCache, useQuery } from '..'
4
6
  import {
5
7
  Blink,
6
8
  createQueryClient,
@@ -20,8 +22,6 @@ import type {
20
22
  UseQueryOptions,
21
23
  UseQueryResult,
22
24
  } from '..'
23
- import { QueryCache, useQuery } from '..'
24
- import { ErrorBoundary } from 'react-error-boundary'
25
25
 
26
26
  describe('useQuery', () => {
27
27
  const queryCache = new QueryCache()
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react'
2
2
  import { act, render } from '@testing-library/react'
3
- import type { ContextOptions, QueryClientConfig, MutationOptions } from '..'
4
- import { QueryClient, QueryClientProvider } from '..'
5
3
  import * as utils from '@tanstack/query-core'
4
+ import { QueryClient, QueryClientProvider } from '..'
5
+ import type { ContextOptions, MutationOptions, QueryClientConfig } from '..'
6
6
 
7
7
  export function renderWithClient(
8
8
  client: QueryClient,
@@ -1,4 +1,6 @@
1
1
  'use client'
2
+ import * as React from 'react'
3
+ import { shouldThrowError } from './utils'
2
4
  import type {
3
5
  DefaultedQueryObserverOptions,
4
6
  Query,
@@ -7,8 +9,6 @@ import type {
7
9
  UseErrorBoundary,
8
10
  } from '@tanstack/query-core'
9
11
  import type { QueryErrorResetBoundaryValue } from './QueryErrorResetBoundary'
10
- import * as React from 'react'
11
- import { shouldThrowError } from './utils'
12
12
 
13
13
  export const ensurePreventErrorBoundaryRetry = <
14
14
  TQueryFnData,
@@ -1,4 +1,5 @@
1
1
  // @ts-ignore
2
2
  // eslint-disable-next-line import/no-unresolved
3
3
  import { unstable_batchedUpdates } from 'react-native'
4
+
4
5
  export { unstable_batchedUpdates }
@@ -1,3 +1,4 @@
1
1
  'use client'
2
2
  import * as ReactDOM from 'react-dom'
3
+
3
4
  export const unstable_batchedUpdates = ReactDOM.unstable_batchedUpdates
package/src/types.ts CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  import type * as React from 'react'
4
4
  import type {
5
+ DefinedQueryObserverResult,
5
6
  InfiniteQueryObserverOptions,
6
7
  InfiniteQueryObserverResult,
8
+ MutateFunction,
9
+ MutationObserverOptions,
7
10
  MutationObserverResult,
11
+ QueryKey,
8
12
  QueryObserverOptions,
9
13
  QueryObserverResult,
10
- QueryKey,
11
- MutationObserverOptions,
12
- MutateFunction,
13
- DefinedQueryObserverResult,
14
14
  } from '@tanstack/query-core'
15
15
  import type { QueryClient } from '@tanstack/query-core'
16
16
 
@@ -1,19 +1,19 @@
1
1
  'use client'
2
2
  import * as React from 'react'
3
- import { useSyncExternalStore } from './useSyncExternalStore'
4
3
 
5
- import type { QueryKey, QueryObserver } from '@tanstack/query-core'
6
4
  import { notifyManager } from '@tanstack/query-core'
5
+ import { useSyncExternalStore } from './useSyncExternalStore'
7
6
  import { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'
8
7
  import { useQueryClient } from './QueryClientProvider'
9
- import type { UseBaseQueryOptions } from './types'
10
8
  import { useIsRestoring } from './isRestoring'
11
9
  import {
12
10
  ensurePreventErrorBoundaryRetry,
13
11
  getHasError,
14
12
  useClearResetErrorBoundary,
15
13
  } from './errorBoundaryUtils'
16
- import { ensureStaleTime, shouldSuspend, fetchOptimistic } from './suspense'
14
+ import { ensureStaleTime, fetchOptimistic, shouldSuspend } from './suspense'
15
+ import type { QueryKey, QueryObserver } from '@tanstack/query-core'
16
+ import type { UseBaseQueryOptions } from './types'
17
17
 
18
18
  export function useBaseQuery<
19
19
  TQueryFnData,
@@ -1,12 +1,12 @@
1
1
  'use client'
2
+ import { InfiniteQueryObserver, parseQueryArgs } from '@tanstack/query-core'
3
+ import { useBaseQuery } from './useBaseQuery'
2
4
  import type {
3
- QueryObserver,
4
5
  QueryFunction,
5
6
  QueryKey,
7
+ QueryObserver,
6
8
  } from '@tanstack/query-core'
7
- import { InfiniteQueryObserver, parseQueryArgs } from '@tanstack/query-core'
8
9
  import type { UseInfiniteQueryOptions, UseInfiniteQueryResult } from './types'
9
- import { useBaseQuery } from './useBaseQuery'
10
10
 
11
11
  // HOOK
12
12
 
@@ -1,11 +1,11 @@
1
1
  'use client'
2
2
  import * as React from 'react'
3
- import type { QueryKey, QueryFilters } from '@tanstack/query-core'
4
3
  import { notifyManager, parseFilterArgs } from '@tanstack/query-core'
5
4
 
6
5
  import { useSyncExternalStore } from './useSyncExternalStore'
7
- import type { ContextOptions } from './types'
8
6
  import { useQueryClient } from './QueryClientProvider'
7
+ import type { ContextOptions } from './types'
8
+ import type { QueryFilters, QueryKey } from '@tanstack/query-core'
9
9
 
10
10
  interface Options extends ContextOptions {}
11
11
 
@@ -1,11 +1,11 @@
1
1
  'use client'
2
2
  import * as React from 'react'
3
+ import { notifyManager, parseMutationFilterArgs } from '@tanstack/query-core'
3
4
  import { useSyncExternalStore } from './useSyncExternalStore'
4
5
 
5
- import type { MutationKey, MutationFilters } from '@tanstack/query-core'
6
- import { notifyManager, parseMutationFilterArgs } from '@tanstack/query-core'
7
- import type { ContextOptions } from './types'
8
6
  import { useQueryClient } from './QueryClientProvider'
7
+ import type { MutationFilters, MutationKey } from '@tanstack/query-core'
8
+ import type { ContextOptions } from './types'
9
9
 
10
10
  interface Options extends ContextOptions {}
11
11
 
@@ -1,20 +1,20 @@
1
1
  'use client'
2
2
  import * as React from 'react'
3
- import { useSyncExternalStore } from './useSyncExternalStore'
4
-
5
- import type { MutationFunction, MutationKey } from '@tanstack/query-core'
6
3
  import {
4
+ MutationObserver,
7
5
  notifyManager,
8
6
  parseMutationArgs,
9
- MutationObserver,
10
7
  } from '@tanstack/query-core'
8
+ import { useSyncExternalStore } from './useSyncExternalStore'
9
+
11
10
  import { useQueryClient } from './QueryClientProvider'
11
+ import { shouldThrowError } from './utils'
12
+ import type { MutationFunction, MutationKey } from '@tanstack/query-core'
12
13
  import type {
13
14
  UseMutateFunction,
14
15
  UseMutationOptions,
15
16
  UseMutationResult,
16
17
  } from './types'
17
- import { shouldThrowError } from './utils'
18
18
 
19
19
  // HOOK
20
20
 
package/src/useQueries.ts CHANGED
@@ -1,11 +1,9 @@
1
1
  'use client'
2
2
  import * as React from 'react'
3
- import { useSyncExternalStore } from './useSyncExternalStore'
4
3
 
5
- import type { QueryKey, QueryFunction } from '@tanstack/query-core'
6
- import { notifyManager, QueriesObserver } from '@tanstack/query-core'
4
+ import { QueriesObserver, notifyManager } from '@tanstack/query-core'
5
+ import { useSyncExternalStore } from './useSyncExternalStore'
7
6
  import { useQueryClient } from './QueryClientProvider'
8
- import type { UseQueryOptions, UseQueryResult } from './types'
9
7
  import { useIsRestoring } from './isRestoring'
10
8
  import { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'
11
9
  import {
@@ -15,10 +13,12 @@ import {
15
13
  } from './errorBoundaryUtils'
16
14
  import {
17
15
  ensureStaleTime,
18
- shouldSuspend,
19
16
  fetchOptimistic,
17
+ shouldSuspend,
20
18
  willFetch,
21
19
  } from './suspense'
20
+ import type { QueryFunction, QueryKey } from '@tanstack/query-core'
21
+ import type { UseQueryOptions, UseQueryResult } from './types'
22
22
 
23
23
  // This defines the `UseQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.
24
24
  // - `context` is omitted as it is passed as a root-level option to `useQueries` instead.
package/src/useQuery.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  'use client'
2
+ import { QueryObserver, parseQueryArgs } from '@tanstack/query-core'
3
+ import { useBaseQuery } from './useBaseQuery'
2
4
  import type { QueryFunction, QueryKey } from '@tanstack/query-core'
3
- import { parseQueryArgs, QueryObserver } from '@tanstack/query-core'
4
5
  import type {
5
6
  DefinedUseQueryResult,
6
7
  UseQueryOptions,
7
8
  UseQueryResult,
8
9
  } from './types'
9
- import { useBaseQuery } from './useBaseQuery'
10
10
 
11
11
  // HOOK
12
12