@tanstack/react-query 4.3.8 → 4.4.0

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 (91) hide show
  1. package/build/lib/Hydrate.d.ts +2 -2
  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/QueryClientProvider.d.ts +2 -2
  6. package/build/lib/QueryClientProvider.esm.js.map +1 -1
  7. package/build/lib/QueryClientProvider.js.map +1 -1
  8. package/build/lib/QueryClientProvider.mjs.map +1 -1
  9. package/build/lib/__tests__/utils.d.ts +2 -1
  10. package/build/lib/types.d.ts +2 -2
  11. package/build/lib/useBaseQuery.d.ts +2 -2
  12. package/build/lib/useBaseQuery.esm.js +1 -1
  13. package/build/lib/useBaseQuery.esm.js.map +1 -1
  14. package/build/lib/useBaseQuery.js +2 -2
  15. package/build/lib/useBaseQuery.js.map +1 -1
  16. package/build/lib/useBaseQuery.mjs +1 -1
  17. package/build/lib/useBaseQuery.mjs.map +1 -1
  18. package/build/lib/useInfiniteQuery.d.ts +2 -2
  19. package/build/lib/useInfiniteQuery.esm.js.map +1 -1
  20. package/build/lib/useInfiniteQuery.js.map +1 -1
  21. package/build/lib/useInfiniteQuery.mjs.map +1 -1
  22. package/build/lib/useIsFetching.d.ts +2 -2
  23. package/build/lib/useIsFetching.esm.js +1 -1
  24. package/build/lib/useIsFetching.esm.js.map +1 -1
  25. package/build/lib/useIsFetching.js +2 -2
  26. package/build/lib/useIsFetching.js.map +1 -1
  27. package/build/lib/useIsFetching.mjs +1 -1
  28. package/build/lib/useIsFetching.mjs.map +1 -1
  29. package/build/lib/useIsMutating.d.ts +2 -2
  30. package/build/lib/useIsMutating.esm.js +1 -1
  31. package/build/lib/useIsMutating.esm.js.map +1 -1
  32. package/build/lib/useIsMutating.js +2 -2
  33. package/build/lib/useIsMutating.js.map +1 -1
  34. package/build/lib/useIsMutating.mjs +1 -1
  35. package/build/lib/useIsMutating.mjs.map +1 -1
  36. package/build/lib/useMutation.d.ts +2 -2
  37. package/build/lib/useMutation.esm.js +1 -1
  38. package/build/lib/useMutation.esm.js.map +1 -1
  39. package/build/lib/useMutation.js +2 -2
  40. package/build/lib/useMutation.js.map +1 -1
  41. package/build/lib/useMutation.mjs +1 -1
  42. package/build/lib/useMutation.mjs.map +1 -1
  43. package/build/lib/useQueries.d.ts +2 -2
  44. package/build/lib/useQueries.esm.js +1 -1
  45. package/build/lib/useQueries.esm.js.map +1 -1
  46. package/build/lib/useQueries.js +2 -2
  47. package/build/lib/useQueries.js.map +1 -1
  48. package/build/lib/useQueries.mjs +1 -1
  49. package/build/lib/useQueries.mjs.map +1 -1
  50. package/build/lib/useQuery.d.ts +2 -2
  51. package/build/lib/useQuery.esm.js.map +1 -1
  52. package/build/lib/useQuery.js.map +1 -1
  53. package/build/lib/useQuery.mjs.map +1 -1
  54. package/build/lib/useSyncExternalStore.d.ts +2 -1
  55. package/build/lib/useSyncExternalStore.esm.js +7 -0
  56. package/build/lib/useSyncExternalStore.esm.js.map +1 -0
  57. package/build/lib/useSyncExternalStore.js +11 -0
  58. package/build/lib/useSyncExternalStore.js.map +1 -0
  59. package/build/lib/useSyncExternalStore.mjs +7 -0
  60. package/build/lib/useSyncExternalStore.mjs.map +1 -0
  61. package/build/lib/useSyncExternalStore.native.d.ts +2 -1
  62. package/build/lib/useSyncExternalStore.native.esm.js +2 -0
  63. package/build/lib/useSyncExternalStore.native.esm.js.map +1 -0
  64. package/build/lib/useSyncExternalStore.native.js +13 -0
  65. package/build/lib/useSyncExternalStore.native.js.map +1 -0
  66. package/build/lib/useSyncExternalStore.native.mjs +2 -0
  67. package/build/lib/useSyncExternalStore.native.mjs.map +1 -0
  68. package/build/umd/index.development.js +8 -5
  69. package/build/umd/index.development.js.map +1 -1
  70. package/build/umd/index.production.js +1 -1
  71. package/build/umd/index.production.js.map +1 -1
  72. package/package.json +2 -2
  73. package/src/Hydrate.tsx +3 -2
  74. package/src/QueryClientProvider.tsx +2 -2
  75. package/src/__tests__/suspense.test.tsx +1 -2
  76. package/src/__tests__/useInfiniteQuery.test.tsx +2 -3
  77. package/src/__tests__/useIsFetching.test.tsx +2 -1
  78. package/src/__tests__/useMutation.test.tsx +3 -2
  79. package/src/__tests__/useQueries.test.tsx +3 -5
  80. package/src/__tests__/useQuery.test.tsx +2 -3
  81. package/src/__tests__/utils.tsx +2 -7
  82. package/src/types.ts +2 -2
  83. package/src/useBaseQuery.ts +3 -2
  84. package/src/useInfiniteQuery.ts +3 -4
  85. package/src/useIsFetching.ts +3 -7
  86. package/src/useIsMutating.ts +3 -7
  87. package/src/useMutation.ts +2 -3
  88. package/src/useQueries.ts +3 -7
  89. package/src/useQuery.ts +7 -7
  90. package/src/useSyncExternalStore.native.ts +3 -1
  91. package/src/useSyncExternalStore.ts +3 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-query",
3
- "version": "4.3.8",
3
+ "version": "4.4.0",
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
  "react-error-boundary": "^3.1.4"
48
48
  },
49
49
  "dependencies": {
50
- "@tanstack/query-core": "4.3.8",
50
+ "@tanstack/query-core": "4.4.0",
51
51
  "use-sync-external-store": "^1.2.0"
52
52
  },
53
53
  "peerDependencies": {
package/src/Hydrate.tsx CHANGED
@@ -1,8 +1,9 @@
1
1
  import * as React from 'react'
2
2
 
3
- import { hydrate, HydrateOptions } from '@tanstack/query-core'
3
+ import type { HydrateOptions } from '@tanstack/query-core'
4
+ import { hydrate } from '@tanstack/query-core'
4
5
  import { useQueryClient } from './QueryClientProvider'
5
- import { ContextOptions } from './types'
6
+ import type { ContextOptions } from './types'
6
7
 
7
8
  export function useHydrate(
8
9
  state: unknown,
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react'
2
2
 
3
- import { QueryClient } from '@tanstack/query-core'
4
- import { ContextOptions } from './types'
3
+ import type { QueryClient } from '@tanstack/query-core'
4
+ import type { ContextOptions } from './types'
5
5
 
6
6
  declare global {
7
7
  interface Window {
@@ -3,14 +3,13 @@ import { ErrorBoundary } from 'react-error-boundary'
3
3
  import * as React from 'react'
4
4
 
5
5
  import { createQueryClient, queryKey, renderWithClient, sleep } from './utils'
6
+ import type { UseInfiniteQueryResult, UseQueryResult } from '..'
6
7
  import {
7
8
  QueryCache,
8
9
  QueryErrorResetBoundary,
9
10
  useInfiniteQuery,
10
- UseInfiniteQueryResult,
11
11
  useQuery,
12
12
  useQueryErrorResetBoundary,
13
- UseQueryResult,
14
13
  } from '..'
15
14
 
16
15
  describe("useQuery's in Suspense mode", () => {
@@ -9,13 +9,12 @@ import {
9
9
  setActTimeout,
10
10
  sleep,
11
11
  } from './utils'
12
- import {
12
+ import type {
13
13
  InfiniteData,
14
- QueryCache,
15
14
  QueryFunctionContext,
16
- useInfiniteQuery,
17
15
  UseInfiniteQueryResult,
18
16
  } from '..'
17
+ import { QueryCache, useInfiniteQuery } from '..'
19
18
 
20
19
  interface Result {
21
20
  items: number[]
@@ -9,7 +9,8 @@ import {
9
9
  setActTimeout,
10
10
  sleep,
11
11
  } from './utils'
12
- import { QueryCache, QueryClient, useIsFetching, useQuery } from '..'
12
+ import type { QueryClient } from '..'
13
+ import { QueryCache, useIsFetching, useQuery } from '..'
13
14
 
14
15
  describe('useIsFetching', () => {
15
16
  // See https://github.com/tannerlinsley/react-query/issues/105
@@ -3,8 +3,9 @@ import '@testing-library/jest-dom'
3
3
  import * as React from 'react'
4
4
  import { ErrorBoundary } from 'react-error-boundary'
5
5
 
6
- import { MutationCache, QueryCache, QueryClient, useMutation } from '..'
7
- import { UseMutationResult } from '../types'
6
+ import type { QueryClient } from '..'
7
+ import { MutationCache, QueryCache, useMutation } from '..'
8
+ import type { UseMutationResult } from '../types'
8
9
  import {
9
10
  createQueryClient,
10
11
  mockNavigatorOnLine,
@@ -12,18 +12,16 @@ import {
12
12
  renderWithClient,
13
13
  sleep,
14
14
  } from './utils'
15
- import {
16
- QueriesObserver,
17
- QueryCache,
15
+ import type {
18
16
  QueryClient,
19
17
  QueryFunction,
20
18
  QueryKey,
21
19
  QueryObserverResult,
22
- useQueries,
23
20
  UseQueryOptions,
24
21
  UseQueryResult,
25
22
  } from '..'
26
- import { QueryFunctionContext } from '@tanstack/query-core'
23
+ import { QueriesObserver, QueryCache, useQueries } from '..'
24
+ import type { QueryFunctionContext } from '@tanstack/query-core'
27
25
 
28
26
  describe('useQueries', () => {
29
27
  const queryCache = new QueryCache()
@@ -13,15 +13,14 @@ import {
13
13
  setActTimeout,
14
14
  sleep,
15
15
  } from './utils'
16
- import {
16
+ import type {
17
17
  DefinedUseQueryResult,
18
- QueryCache,
19
18
  QueryFunction,
20
19
  QueryFunctionContext,
21
- useQuery,
22
20
  UseQueryOptions,
23
21
  UseQueryResult,
24
22
  } from '..'
23
+ import { QueryCache, useQuery } from '..'
25
24
  import { ErrorBoundary } from 'react-error-boundary'
26
25
 
27
26
  describe('useQuery', () => {
@@ -1,12 +1,7 @@
1
1
  import * as React from 'react'
2
2
  import { act, render } from '@testing-library/react'
3
- import {
4
- QueryClient,
5
- ContextOptions,
6
- QueryClientProvider,
7
- QueryClientConfig,
8
- MutationOptions,
9
- } from '..'
3
+ import type { ContextOptions, QueryClientConfig, MutationOptions } from '..'
4
+ import { QueryClient, QueryClientProvider } from '..'
10
5
  import * as utils from '@tanstack/query-core'
11
6
 
12
7
  export function renderWithClient(
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
- import * as React from 'react'
2
- import {
1
+ import type * as React from 'react'
2
+ import type {
3
3
  InfiniteQueryObserverOptions,
4
4
  InfiniteQueryObserverResult,
5
5
  MutationObserverResult,
@@ -1,10 +1,11 @@
1
1
  import * as React from 'react'
2
2
  import { useSyncExternalStore } from './useSyncExternalStore'
3
3
 
4
- import { QueryKey, notifyManager, QueryObserver } from '@tanstack/query-core'
4
+ import type { QueryKey, QueryObserver } from '@tanstack/query-core'
5
+ import { notifyManager } from '@tanstack/query-core'
5
6
  import { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'
6
7
  import { useQueryClient } from './QueryClientProvider'
7
- import { UseBaseQueryOptions } from './types'
8
+ import type { UseBaseQueryOptions } from './types'
8
9
  import { shouldThrowError } from './utils'
9
10
  import { useIsRestoring } from './isRestoring'
10
11
 
@@ -1,11 +1,10 @@
1
- import {
1
+ import type {
2
2
  QueryObserver,
3
- InfiniteQueryObserver,
4
3
  QueryFunction,
5
4
  QueryKey,
6
- parseQueryArgs,
7
5
  } from '@tanstack/query-core'
8
- import { UseInfiniteQueryOptions, UseInfiniteQueryResult } from './types'
6
+ import { InfiniteQueryObserver, parseQueryArgs } from '@tanstack/query-core'
7
+ import type { UseInfiniteQueryOptions, UseInfiniteQueryResult } from './types'
9
8
  import { useBaseQuery } from './useBaseQuery'
10
9
 
11
10
  // HOOK
@@ -1,13 +1,9 @@
1
1
  import * as React from 'react'
2
- import {
3
- QueryKey,
4
- notifyManager,
5
- parseFilterArgs,
6
- QueryFilters,
7
- } from '@tanstack/query-core'
2
+ import type { QueryKey, QueryFilters } from '@tanstack/query-core'
3
+ import { notifyManager, parseFilterArgs } from '@tanstack/query-core'
8
4
 
9
5
  import { useSyncExternalStore } from './useSyncExternalStore'
10
- import { ContextOptions } from './types'
6
+ import type { ContextOptions } from './types'
11
7
  import { useQueryClient } from './QueryClientProvider'
12
8
 
13
9
  interface Options extends ContextOptions {}
@@ -1,13 +1,9 @@
1
1
  import * as React from 'react'
2
2
  import { useSyncExternalStore } from './useSyncExternalStore'
3
3
 
4
- import {
5
- notifyManager,
6
- MutationKey,
7
- MutationFilters,
8
- parseMutationFilterArgs,
9
- } from '@tanstack/query-core'
10
- import { ContextOptions } from './types'
4
+ import type { MutationKey, MutationFilters } from '@tanstack/query-core'
5
+ import { notifyManager, parseMutationFilterArgs } from '@tanstack/query-core'
6
+ import type { ContextOptions } from './types'
11
7
  import { useQueryClient } from './QueryClientProvider'
12
8
 
13
9
  interface Options extends ContextOptions {}
@@ -1,15 +1,14 @@
1
1
  import * as React from 'react'
2
2
  import { useSyncExternalStore } from './useSyncExternalStore'
3
3
 
4
+ import type { MutationFunction, MutationKey } from '@tanstack/query-core'
4
5
  import {
5
6
  notifyManager,
6
7
  parseMutationArgs,
7
8
  MutationObserver,
8
- MutationFunction,
9
- MutationKey,
10
9
  } from '@tanstack/query-core'
11
10
  import { useQueryClient } from './QueryClientProvider'
12
- import {
11
+ import type {
13
12
  UseMutateFunction,
14
13
  UseMutationOptions,
15
14
  UseMutationResult,
package/src/useQueries.ts CHANGED
@@ -1,14 +1,10 @@
1
1
  import * as React from 'react'
2
2
  import { useSyncExternalStore } from './useSyncExternalStore'
3
3
 
4
- import {
5
- QueryKey,
6
- QueryFunction,
7
- notifyManager,
8
- QueriesObserver,
9
- } from '@tanstack/query-core'
4
+ import type { QueryKey, QueryFunction } from '@tanstack/query-core'
5
+ import { notifyManager, QueriesObserver } from '@tanstack/query-core'
10
6
  import { useQueryClient } from './QueryClientProvider'
11
- import { UseQueryOptions, UseQueryResult } from './types'
7
+ import type { UseQueryOptions, UseQueryResult } from './types'
12
8
  import { useIsRestoring } from './isRestoring'
13
9
 
14
10
  // This defines the `UseQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.
package/src/useQuery.ts CHANGED
@@ -1,10 +1,10 @@
1
- import {
2
- parseQueryArgs,
3
- QueryFunction,
4
- QueryKey,
5
- QueryObserver,
6
- } from '@tanstack/query-core'
7
- import { DefinedUseQueryResult, UseQueryOptions, UseQueryResult } from './types'
1
+ import type { QueryFunction, QueryKey } from '@tanstack/query-core'
2
+ import { parseQueryArgs, QueryObserver } from '@tanstack/query-core'
3
+ import type {
4
+ DefinedUseQueryResult,
5
+ UseQueryOptions,
6
+ UseQueryResult,
7
+ } from './types'
8
8
  import { useBaseQuery } from './useBaseQuery'
9
9
 
10
10
  // HOOK
@@ -1,3 +1,5 @@
1
1
  // Temporary workaround due to an issue with react-native uSES - https://github.com/TanStack/query/pull/3601
2
2
  // @ts-ignore
3
- export { useSyncExternalStore } from 'use-sync-external-store/shim/index.native.js'
3
+ import { useSyncExternalStore } from 'use-sync-external-store/shim/index.native.js'
4
+
5
+ export { useSyncExternalStore }
@@ -1,2 +1,4 @@
1
1
  // Temporary workaround due to an issue with react-native uSES - https://github.com/TanStack/query/pull/3601
2
- export { useSyncExternalStore } from 'use-sync-external-store/shim/index.js'
2
+ import { useSyncExternalStore as uSES } from 'use-sync-external-store/shim/index.js'
3
+
4
+ export const useSyncExternalStore = uSES