@tanstack/react-query 4.0.10 → 4.0.11-beta.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.
Files changed (105) hide show
  1. package/build/{types/packages/react-query/src → lib}/Hydrate.d.ts +0 -0
  2. package/build/{types/packages/react-query/src → lib}/QueryClientProvider.d.ts +0 -0
  3. package/build/{types/packages/react-query/src → lib}/QueryErrorResetBoundary.d.ts +0 -0
  4. package/build/{types/packages/react-query/src → lib}/index.d.ts +0 -0
  5. package/build/lib/index.js +625 -0
  6. package/build/lib/index.js.map +1 -0
  7. package/build/lib/index.mjs +579 -0
  8. package/build/lib/index.mjs.map +1 -0
  9. package/build/{types/packages/react-query/src → lib}/isRestoring.d.ts +0 -0
  10. package/build/{types/packages/react-query/src → lib}/reactBatchedUpdates.d.ts +0 -0
  11. package/build/{types/packages/react-query/src → lib}/reactBatchedUpdates.native.d.ts +0 -0
  12. package/build/{types/packages/react-query/src → lib}/setBatchUpdatesFn.d.ts +0 -0
  13. package/build/{types/packages/react-query/src → lib}/types.d.ts +3 -4
  14. package/build/{types/packages/react-query/src → lib}/useBaseQuery.d.ts +0 -0
  15. package/build/{types/packages/react-query/src → lib}/useInfiniteQuery.d.ts +0 -0
  16. package/build/{types/packages/react-query/src → lib}/useIsFetching.d.ts +0 -0
  17. package/build/{types/packages/react-query/src → lib}/useIsMutating.d.ts +0 -0
  18. package/build/{types/packages/react-query/src → lib}/useMutation.d.ts +0 -0
  19. package/build/{types/packages/react-query/src → lib}/useQueries.d.ts +0 -0
  20. package/build/{types/packages/react-query/src → lib}/useQuery.d.ts +0 -0
  21. package/build/lib/useSyncExternalStore.d.ts +1 -0
  22. package/build/lib/useSyncExternalStore.native.d.ts +1 -0
  23. package/build/{types/packages/react-query/src → lib}/utils.d.ts +0 -0
  24. package/build/umd/index.development.js +293 -15
  25. package/build/umd/index.development.js.map +1 -1
  26. package/build/umd/index.production.js +3 -2
  27. package/build/umd/index.production.js.map +1 -1
  28. package/package.json +18 -15
  29. package/src/__tests__/useQuery.test.tsx +10 -8
  30. package/src/types.ts +10 -4
  31. package/src/useBaseQuery.ts +1 -1
  32. package/src/useIsFetching.ts +1 -1
  33. package/src/useIsMutating.ts +1 -1
  34. package/src/useMutation.ts +1 -1
  35. package/src/useQueries.ts +1 -1
  36. package/src/useSyncExternalStore.native.ts +3 -0
  37. package/src/useSyncExternalStore.ts +2 -0
  38. package/build/cjs/query-core/build/esm/index.js +0 -3110
  39. package/build/cjs/query-core/build/esm/index.js.map +0 -1
  40. package/build/cjs/react-query/src/Hydrate.js +0 -66
  41. package/build/cjs/react-query/src/Hydrate.js.map +0 -1
  42. package/build/cjs/react-query/src/QueryClientProvider.js +0 -96
  43. package/build/cjs/react-query/src/QueryClientProvider.js.map +0 -1
  44. package/build/cjs/react-query/src/QueryErrorResetBoundary.js +0 -67
  45. package/build/cjs/react-query/src/QueryErrorResetBoundary.js.map +0 -1
  46. package/build/cjs/react-query/src/index.js +0 -64
  47. package/build/cjs/react-query/src/index.js.map +0 -1
  48. package/build/cjs/react-query/src/isRestoring.js +0 -43
  49. package/build/cjs/react-query/src/isRestoring.js.map +0 -1
  50. package/build/cjs/react-query/src/useBaseQuery.js +0 -117
  51. package/build/cjs/react-query/src/useBaseQuery.js.map +0 -1
  52. package/build/cjs/react-query/src/useInfiniteQuery.js +0 -24
  53. package/build/cjs/react-query/src/useInfiniteQuery.js.map +0 -1
  54. package/build/cjs/react-query/src/useIsFetching.js +0 -50
  55. package/build/cjs/react-query/src/useIsFetching.js.map +0 -1
  56. package/build/cjs/react-query/src/useIsMutating.js +0 -50
  57. package/build/cjs/react-query/src/useIsMutating.js.map +0 -1
  58. package/build/cjs/react-query/src/useMutation.js +0 -68
  59. package/build/cjs/react-query/src/useMutation.js.map +0 -1
  60. package/build/cjs/react-query/src/useQueries.js +0 -71
  61. package/build/cjs/react-query/src/useQueries.js.map +0 -1
  62. package/build/cjs/react-query/src/useQuery.js +0 -24
  63. package/build/cjs/react-query/src/useQuery.js.map +0 -1
  64. package/build/cjs/react-query/src/utils.js +0 -25
  65. package/build/cjs/react-query/src/utils.js.map +0 -1
  66. package/build/esm/index.js +0 -3368
  67. package/build/esm/index.js.map +0 -1
  68. package/build/stats-html.html +0 -2689
  69. package/build/stats.json +0 -666
  70. package/build/types/packages/query-core/src/focusManager.d.ts +0 -16
  71. package/build/types/packages/query-core/src/hydration.d.ts +0 -34
  72. package/build/types/packages/query-core/src/index.d.ts +0 -20
  73. package/build/types/packages/query-core/src/infiniteQueryBehavior.d.ts +0 -15
  74. package/build/types/packages/query-core/src/infiniteQueryObserver.d.ts +0 -18
  75. package/build/types/packages/query-core/src/logger.d.ts +0 -8
  76. package/build/types/packages/query-core/src/mutation.d.ts +0 -70
  77. package/build/types/packages/query-core/src/mutationCache.d.ts +0 -52
  78. package/build/types/packages/query-core/src/mutationObserver.d.ts +0 -23
  79. package/build/types/packages/query-core/src/notifyManager.d.ts +0 -18
  80. package/build/types/packages/query-core/src/onlineManager.d.ts +0 -16
  81. package/build/types/packages/query-core/src/queriesObserver.d.ts +0 -23
  82. package/build/types/packages/query-core/src/query.d.ts +0 -119
  83. package/build/types/packages/query-core/src/queryCache.d.ts +0 -59
  84. package/build/types/packages/query-core/src/queryClient.d.ts +0 -65
  85. package/build/types/packages/query-core/src/queryObserver.d.ts +0 -61
  86. package/build/types/packages/query-core/src/removable.d.ts +0 -9
  87. package/build/types/packages/query-core/src/retryer.d.ts +0 -33
  88. package/build/types/packages/query-core/src/subscribable.d.ts +0 -10
  89. package/build/types/packages/query-core/src/types.d.ts +0 -417
  90. package/build/types/packages/query-core/src/utils.d.ts +0 -99
  91. package/build/types/packages/react-query/src/__tests__/Hydrate.test.d.ts +0 -1
  92. package/build/types/packages/react-query/src/__tests__/QueryClientProvider.test.d.ts +0 -1
  93. package/build/types/packages/react-query/src/__tests__/QueryResetErrorBoundary.test.d.ts +0 -6
  94. package/build/types/packages/react-query/src/__tests__/ssr-hydration.test.d.ts +0 -1
  95. package/build/types/packages/react-query/src/__tests__/ssr.test.d.ts +0 -4
  96. package/build/types/packages/react-query/src/__tests__/suspense.test.d.ts +0 -1
  97. package/build/types/packages/react-query/src/__tests__/useInfiniteQuery.test.d.ts +0 -1
  98. package/build/types/packages/react-query/src/__tests__/useIsFetching.test.d.ts +0 -1
  99. package/build/types/packages/react-query/src/__tests__/useIsMutating.test.d.ts +0 -1
  100. package/build/types/packages/react-query/src/__tests__/useMutation.test.d.ts +0 -1
  101. package/build/types/packages/react-query/src/__tests__/useQueries.test.d.ts +0 -1
  102. package/build/types/packages/react-query/src/__tests__/useQuery.test.d.ts +0 -1
  103. package/build/types/packages/react-query/src/__tests__/useQuery.types.test.d.ts +0 -2
  104. package/build/types/packages/react-query/src/__tests__/utils.d.ts +0 -8
  105. package/build/types/tests/utils.d.ts +0 -24
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-query",
3
- "version": "4.0.10",
3
+ "version": "4.0.11-beta.4",
4
4
  "description": "Hooks for managing, caching and syncing asynchronous and remote data in React",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -10,27 +10,30 @@
10
10
  "type": "github",
11
11
  "url": "https://github.com/sponsors/tannerlinsley"
12
12
  },
13
- "module": "build/esm/index.js",
14
- "main": "build/cjs/react-query/src/index.js",
15
- "browser": "build/umd/index.production.js",
16
- "types": "build/types/packages/react-query/src/index.d.ts",
13
+ "types": "build/lib/index.d.ts",
14
+ "module": "build/lib/index.mjs",
15
+ "main": "build/lib/index.js",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./build/lib/index.d.ts",
19
+ "import": "./build/lib/index.mjs",
20
+ "default": "./build/lib/index.js"
21
+ },
22
+ "./package.json": "./package.json"
23
+ },
17
24
  "sideEffects": [
18
- "lib/index.js",
19
- "lib/index.mjs",
20
- "lib/reactjs/index.js",
21
- "lib/reactjs/index.mjs",
22
- "lib/reactjs/setBatchUpdatesFn.js",
23
- "lib/reactjs/setBatchUpdatesFn.mjs"
25
+ "./src/setBatchUpdatesFn.ts"
24
26
  ],
25
27
  "scripts": {
28
+ "clean": "rm -rf ./build",
26
29
  "test:codemods": "../../node_modules/.bin/jest --config codemods/jest.config.js",
27
30
  "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src",
28
31
  "test:jest": "yarn test:codemods && ../../node_modules/.bin/jest --config jest.config.js",
29
- "test:jest:dev": "yarn test:jest --watch",
30
- "compile": "../../node_modules/.bin/tsc -p tsconfig.json --noEmit --emitDeclarationOnly false"
32
+ "test:jest:dev": "yarn test:jest --watch"
31
33
  },
32
34
  "files": [
33
- "build/*",
35
+ "build/lib/*",
36
+ "build/umd/*",
34
37
  "src",
35
38
  "codemods",
36
39
  "!codemods/jest.config.js",
@@ -43,7 +46,7 @@
43
46
  "react-error-boundary": "^3.1.4"
44
47
  },
45
48
  "dependencies": {
46
- "@tanstack/query-core": "^4.0.0-beta.1",
49
+ "@tanstack/query-core": "^4.0.10",
47
50
  "@types/use-sync-external-store": "^0.0.3",
48
51
  "use-sync-external-store": "^1.2.0"
49
52
  },
@@ -2149,14 +2149,16 @@ describe('useQuery', () => {
2149
2149
  await sleep(20)
2150
2150
  unsubscribe()
2151
2151
 
2152
- // 1. Subscribe observer
2153
- // 2. Query loading
2154
- // 3. Observer loading
2155
- // 4. Query success
2156
- // 5. Observer success
2157
- // 6. Query stale
2158
- // 7. Unsubscribe observer
2159
- expect(fn).toHaveBeenCalledTimes(7)
2152
+ // 1. Query added -> loading
2153
+ // 2. Observer result updated -> loading
2154
+ // 3. Observer added
2155
+ // 4. Query updated -> success
2156
+ // 5. Observer result updated -> success
2157
+ // 6. Query updated -> stale
2158
+ // 7. Observer options updated
2159
+ // 8. Observer result updated -> stale
2160
+ // 9. Observer options updated
2161
+ expect(fn).toHaveBeenCalledTimes(9)
2160
2162
  })
2161
2163
 
2162
2164
  it('should not re-render when it should only re-render on data changes and the data did not change', async () => {
package/src/types.ts CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  QueryKey,
9
9
  MutationObserverOptions,
10
10
  MutateFunction,
11
+ DefinedQueryObserverResult,
11
12
  } from '@tanstack/query-core'
12
13
  import type { QueryClient } from '@tanstack/query-core'
13
14
 
@@ -65,10 +66,15 @@ export type UseQueryResult<
65
66
  TError = unknown,
66
67
  > = UseBaseQueryResult<TData, TError>
67
68
 
68
- export type DefinedUseQueryResult<TData = unknown, TError = unknown> = Omit<
69
- UseQueryResult<TData, TError>,
70
- 'data'
71
- > & { data: TData }
69
+ export type DefinedUseBaseQueryResult<
70
+ TData = unknown,
71
+ TError = unknown,
72
+ > = DefinedQueryObserverResult<TData, TError>
73
+
74
+ export type DefinedUseQueryResult<
75
+ TData = unknown,
76
+ TError = unknown,
77
+ > = DefinedUseBaseQueryResult<TData, TError>
72
78
 
73
79
  export type UseInfiniteQueryResult<
74
80
  TData = unknown,
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react'
2
- import { useSyncExternalStore } from 'use-sync-external-store/shim'
2
+ import { useSyncExternalStore } from './useSyncExternalStore'
3
3
 
4
4
  import { QueryKey, notifyManager, QueryObserver } from '@tanstack/query-core'
5
5
  import { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'
@@ -6,7 +6,7 @@ import {
6
6
  QueryFilters,
7
7
  } from '@tanstack/query-core'
8
8
 
9
- import { useSyncExternalStore } from 'use-sync-external-store/shim'
9
+ import { useSyncExternalStore } from './useSyncExternalStore'
10
10
  import { ContextOptions } from './types'
11
11
  import { useQueryClient } from './QueryClientProvider'
12
12
 
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react'
2
- import { useSyncExternalStore } from 'use-sync-external-store/shim'
2
+ import { useSyncExternalStore } from './useSyncExternalStore'
3
3
 
4
4
  import {
5
5
  notifyManager,
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react'
2
- import { useSyncExternalStore } from 'use-sync-external-store/shim'
2
+ import { useSyncExternalStore } from './useSyncExternalStore'
3
3
 
4
4
  import {
5
5
  notifyManager,
package/src/useQueries.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react'
2
- import { useSyncExternalStore } from 'use-sync-external-store/shim'
2
+ import { useSyncExternalStore } from './useSyncExternalStore'
3
3
 
4
4
  import {
5
5
  QueryKey,
@@ -0,0 +1,3 @@
1
+ // Temporary workaround due to an issue with react-native uSES - https://github.com/TanStack/query/pull/3601
2
+ // @ts-ignore
3
+ export { useSyncExternalStore } from 'use-sync-external-store/shim/index.native.js'
@@ -0,0 +1,2 @@
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'