@tanstack/react-query 5.0.0 → 5.4.3
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/README.md +3 -6
- package/build/codemods/coverage/clover.xml +2 -2
- package/build/codemods/coverage/index.html +1 -1
- package/build/codemods/src/v5/remove-overloads/remove-overloads.js +1 -1
- package/build/codemods/src/v5/remove-overloads/transformers/filter-aware-usage-transformer.js +32 -6
- package/build/legacy/QueryErrorResetBoundary.d.cts +1 -1
- package/build/legacy/QueryErrorResetBoundary.d.ts +1 -1
- package/build/legacy/suspense.cjs.map +1 -1
- package/build/legacy/suspense.js.map +1 -1
- package/build/modern/QueryErrorResetBoundary.d.cts +1 -1
- package/build/modern/QueryErrorResetBoundary.d.ts +1 -1
- package/build/modern/suspense.cjs.map +1 -1
- package/build/modern/suspense.js.map +1 -1
- package/package.json +4 -4
- package/src/__tests__/HydrationBoundary.test.tsx +1 -0
- package/src/__tests__/QueryClientProvider.test.tsx +1 -0
- package/src/__tests__/QueryResetErrorBoundary.test.tsx +1 -0
- package/src/__tests__/fine-grained-persister.test.tsx +1 -2
- package/src/__tests__/infiniteQueryOptions.types.test.tsx +1 -0
- package/src/__tests__/queryOptions.types.test.tsx +1 -0
- package/src/__tests__/ssr-hydration.test.tsx +1 -3
- package/src/__tests__/ssr.test.tsx +1 -2
- package/src/__tests__/suspense.test.tsx +3 -3
- package/src/__tests__/suspense.types.test.tsx +1 -0
- package/src/__tests__/useInfiniteQuery.test.tsx +1 -2
- package/src/__tests__/useInfiniteQuery.type.test.tsx +1 -0
- package/src/__tests__/useIsFetching.test.tsx +1 -1
- package/src/__tests__/useMutation.test.tsx +1 -3
- package/src/__tests__/useMutationState.test.tsx +1 -0
- package/src/__tests__/useQueries.test.tsx +1 -2
- package/src/__tests__/useQuery.test.tsx +3 -4
- package/src/__tests__/useQuery.types.test.tsx +1 -0
- package/src/__tests__/utils.tsx +1 -2
- package/src/suspense.ts +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<img src="https://static.scarf.sh/a.png?x-pxid=be2d8a11-9712-4c1d-9963-580b2d4fb133" />
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
5
|
Hooks for fetching, caching and updating asynchronous data in React
|
|
6
6
|
|
|
@@ -12,8 +12,8 @@ Hooks for fetching, caching and updating asynchronous data in React
|
|
|
12
12
|
<img src="https://github.com/TanStack/query/workflows/react-query%20tests/badge.svg" />
|
|
13
13
|
</a><a href="https://www.npmjs.com/package/@tanstack/query-core" target="\_parent">
|
|
14
14
|
<img alt="" src="https://img.shields.io/npm/dm/@tanstack/query-core.svg" />
|
|
15
|
-
</a><a href="https://
|
|
16
|
-
<img alt="" src="https://
|
|
15
|
+
</a><a href="https://bundlejs.com/?q=%40tanstack%2Freact-query&config=%7B%22esbuild%22%3A%7B%22external%22%3A%5B%22react%22%2C%22react-dom%22%5D%7D%7D&badge=" target="\_parent">
|
|
16
|
+
<img alt="" src="https://deno.bundlejs.com/?q=@tanstack/react-query&config={%22esbuild%22:{%22external%22:[%22react%22,%22react-dom%22]}}&badge=detailed" />
|
|
17
17
|
</a><a href="#badge">
|
|
18
18
|
<img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg">
|
|
19
19
|
</a><a href="https://github.com/TanStack/query/discussions">
|
|
@@ -42,9 +42,6 @@ Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [TanStack T
|
|
|
42
42
|
- Request Cancellation
|
|
43
43
|
- [React Suspense](https://reactjs.org/docs/concurrent-mode-suspense.html) + Fetch-As-You-Render Query Prefetching
|
|
44
44
|
- Dedicated Devtools
|
|
45
|
-
- <a href="https://bundlephobia.com/package/@tanstack/react-query@latest" target="\_parent">
|
|
46
|
-
<img alt="" src="https://badgen.net/bundlephobia/minzip/@tanstack/react-query" />
|
|
47
|
-
</a> (depending on features imported)
|
|
48
45
|
|
|
49
46
|
### [Become a Sponsor!](https://github.com/sponsors/tannerlinsley/)
|
|
50
47
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<coverage generated="
|
|
3
|
-
<project timestamp="
|
|
2
|
+
<coverage generated="1697964750272" clover="3.2.0">
|
|
3
|
+
<project timestamp="1697964750272" name="All files">
|
|
4
4
|
<metrics statements="0" coveredstatements="0" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0" elements="0" coveredelements="0" complexity="0" loc="0" ncloc="0" packages="0" files="0" classes="0"/>
|
|
5
5
|
</project>
|
|
6
6
|
</coverage>
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
87
87
|
Code coverage generated by
|
|
88
88
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
89
|
-
at 2023-
|
|
89
|
+
at 2023-10-22T08:52:30.227Z
|
|
90
90
|
</div>
|
|
91
91
|
<script src="prettify.js"></script>
|
|
92
92
|
<script>
|
package/build/codemods/src/v5/remove-overloads/transformers/filter-aware-usage-transformer.js
CHANGED
|
@@ -94,14 +94,40 @@ const transformFilterAwareUsages = ({
|
|
|
94
94
|
* it will notify the consumers that they need to rewrite this usage manually.
|
|
95
95
|
*/
|
|
96
96
|
if (!keyProperty) {
|
|
97
|
-
|
|
97
|
+
const secondArgument =
|
|
98
|
+
node.arguments.length > 1 ? node.arguments[1] : null
|
|
99
|
+
|
|
100
|
+
if (!secondArgument) {
|
|
101
|
+
throw new UnknownUsageError(node, filePath)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (utils.isFunctionDefinition(secondArgument)) {
|
|
105
|
+
const originalArguments = node.arguments
|
|
106
|
+
const firstArgument = jscodeshift.objectExpression([
|
|
107
|
+
jscodeshift.property(
|
|
108
|
+
'init',
|
|
109
|
+
jscodeshift.identifier('queryKey'),
|
|
110
|
+
originalArguments[0],
|
|
111
|
+
),
|
|
112
|
+
jscodeshift.property(
|
|
113
|
+
'init',
|
|
114
|
+
jscodeshift.identifier('queryFn'),
|
|
115
|
+
secondArgument,
|
|
116
|
+
),
|
|
117
|
+
])
|
|
118
|
+
|
|
119
|
+
return jscodeshift.callExpression(node.original.callee, [
|
|
120
|
+
firstArgument,
|
|
121
|
+
...originalArguments.slice(2),
|
|
122
|
+
])
|
|
123
|
+
}
|
|
98
124
|
}
|
|
99
125
|
|
|
100
|
-
const
|
|
126
|
+
const functionArguments = [jscodeshift.objectExpression([keyProperty])]
|
|
101
127
|
const secondParameter = node.arguments[1]
|
|
102
128
|
|
|
103
129
|
if (secondParameter) {
|
|
104
|
-
const createdObjectExpression =
|
|
130
|
+
const createdObjectExpression = functionArguments[0]
|
|
105
131
|
|
|
106
132
|
/**
|
|
107
133
|
* If it has a second argument, and it's an object expression, then we get the properties from it
|
|
@@ -122,10 +148,10 @@ const transformFilterAwareUsages = ({
|
|
|
122
148
|
}
|
|
123
149
|
}
|
|
124
150
|
|
|
125
|
-
// The rest of the
|
|
126
|
-
|
|
151
|
+
// The rest of the function arguments can be simply pushed to the function arguments object so all will be kept.
|
|
152
|
+
functionArguments.push(...node.arguments.slice(2))
|
|
127
153
|
|
|
128
|
-
return jscodeshift.callExpression(node.original.callee,
|
|
154
|
+
return jscodeshift.callExpression(node.original.callee, functionArguments)
|
|
129
155
|
} catch (error) {
|
|
130
156
|
utils.warn(
|
|
131
157
|
error.name === UnknownUsageError.name
|
|
@@ -9,6 +9,6 @@ declare const useQueryErrorResetBoundary: () => QueryErrorResetBoundaryValue;
|
|
|
9
9
|
interface QueryErrorResetBoundaryProps {
|
|
10
10
|
children: ((value: QueryErrorResetBoundaryValue) => React.ReactNode) | React.ReactNode;
|
|
11
11
|
}
|
|
12
|
-
declare const QueryErrorResetBoundary: ({ children, }: QueryErrorResetBoundaryProps) => JSX.Element;
|
|
12
|
+
declare const QueryErrorResetBoundary: ({ children, }: QueryErrorResetBoundaryProps) => React.JSX.Element;
|
|
13
13
|
|
|
14
14
|
export { QueryErrorResetBoundary, QueryErrorResetBoundaryProps, QueryErrorResetBoundaryValue, useQueryErrorResetBoundary };
|
|
@@ -9,6 +9,6 @@ declare const useQueryErrorResetBoundary: () => QueryErrorResetBoundaryValue;
|
|
|
9
9
|
interface QueryErrorResetBoundaryProps {
|
|
10
10
|
children: ((value: QueryErrorResetBoundaryValue) => React.ReactNode) | React.ReactNode;
|
|
11
11
|
}
|
|
12
|
-
declare const QueryErrorResetBoundary: ({ children, }: QueryErrorResetBoundaryProps) => JSX.Element;
|
|
12
|
+
declare const QueryErrorResetBoundary: ({ children, }: QueryErrorResetBoundaryProps) => React.JSX.Element;
|
|
13
13
|
|
|
14
14
|
export { QueryErrorResetBoundary, QueryErrorResetBoundaryProps, QueryErrorResetBoundaryValue, useQueryErrorResetBoundary };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/suspense.ts"],"sourcesContent":["import type { DefaultError } from '@tanstack/query-core
|
|
1
|
+
{"version":3,"sources":["../../src/suspense.ts"],"sourcesContent":["import type { DefaultError } from '@tanstack/query-core'\nimport type {\n DefaultedQueryObserverOptions,\n Query,\n QueryKey,\n QueryObserver,\n QueryObserverResult,\n} from '@tanstack/query-core'\nimport type { QueryErrorResetBoundaryValue } from './QueryErrorResetBoundary'\n\nexport const defaultThrowOnError = <\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n _error: TError,\n query: Query<TQueryFnData, TError, TData, TQueryKey>,\n) => typeof query.state.data === 'undefined'\n\nexport const ensureStaleTime = (\n defaultedOptions: DefaultedQueryObserverOptions<any, any, any, any, any>,\n) => {\n if (defaultedOptions.suspense) {\n // Always set stale time when using suspense to prevent\n // fetching again when directly mounting after suspending\n if (typeof defaultedOptions.staleTime !== 'number') {\n defaultedOptions.staleTime = 1000\n }\n }\n}\n\nexport const willFetch = (\n result: QueryObserverResult<any, any>,\n isRestoring: boolean,\n) => result.isLoading && result.isFetching && !isRestoring\n\nexport const shouldSuspend = (\n defaultedOptions:\n | DefaultedQueryObserverOptions<any, any, any, any, any>\n | undefined,\n result: QueryObserverResult<any, any>,\n isRestoring: boolean,\n) => defaultedOptions?.suspense && willFetch(result, isRestoring)\n\nexport const fetchOptimistic = <\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n defaultedOptions: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n observer: QueryObserver<TQueryFnData, TError, TData, TQueryData, TQueryKey>,\n errorResetBoundary: QueryErrorResetBoundaryValue,\n) =>\n observer.fetchOptimistic(defaultedOptions).catch(() => {\n errorResetBoundary.clearReset()\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,IAAM,sBAAsB,CAMjC,QACA,UACG,OAAO,MAAM,MAAM,SAAS;AAE1B,IAAM,kBAAkB,CAC7B,qBACG;AACH,MAAI,iBAAiB,UAAU;AAG7B,QAAI,OAAO,iBAAiB,cAAc,UAAU;AAClD,uBAAiB,YAAY;AAAA,IAC/B;AAAA,EACF;AACF;AAEO,IAAM,YAAY,CACvB,QACA,gBACG,OAAO,aAAa,OAAO,cAAc,CAAC;AAExC,IAAM,gBAAgB,CAC3B,kBAGA,QACA,iBACG,qDAAkB,aAAY,UAAU,QAAQ,WAAW;AAEzD,IAAM,kBAAkB,CAO7B,kBAOA,UACA,uBAEA,SAAS,gBAAgB,gBAAgB,EAAE,MAAM,MAAM;AACrD,qBAAmB,WAAW;AAChC,CAAC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/suspense.ts"],"sourcesContent":["import type { DefaultError } from '@tanstack/query-core
|
|
1
|
+
{"version":3,"sources":["../../src/suspense.ts"],"sourcesContent":["import type { DefaultError } from '@tanstack/query-core'\nimport type {\n DefaultedQueryObserverOptions,\n Query,\n QueryKey,\n QueryObserver,\n QueryObserverResult,\n} from '@tanstack/query-core'\nimport type { QueryErrorResetBoundaryValue } from './QueryErrorResetBoundary'\n\nexport const defaultThrowOnError = <\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n _error: TError,\n query: Query<TQueryFnData, TError, TData, TQueryKey>,\n) => typeof query.state.data === 'undefined'\n\nexport const ensureStaleTime = (\n defaultedOptions: DefaultedQueryObserverOptions<any, any, any, any, any>,\n) => {\n if (defaultedOptions.suspense) {\n // Always set stale time when using suspense to prevent\n // fetching again when directly mounting after suspending\n if (typeof defaultedOptions.staleTime !== 'number') {\n defaultedOptions.staleTime = 1000\n }\n }\n}\n\nexport const willFetch = (\n result: QueryObserverResult<any, any>,\n isRestoring: boolean,\n) => result.isLoading && result.isFetching && !isRestoring\n\nexport const shouldSuspend = (\n defaultedOptions:\n | DefaultedQueryObserverOptions<any, any, any, any, any>\n | undefined,\n result: QueryObserverResult<any, any>,\n isRestoring: boolean,\n) => defaultedOptions?.suspense && willFetch(result, isRestoring)\n\nexport const fetchOptimistic = <\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n defaultedOptions: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n observer: QueryObserver<TQueryFnData, TError, TData, TQueryData, TQueryKey>,\n errorResetBoundary: QueryErrorResetBoundaryValue,\n) =>\n observer.fetchOptimistic(defaultedOptions).catch(() => {\n errorResetBoundary.clearReset()\n })\n"],"mappings":";AAUO,IAAM,sBAAsB,CAMjC,QACA,UACG,OAAO,MAAM,MAAM,SAAS;AAE1B,IAAM,kBAAkB,CAC7B,qBACG;AACH,MAAI,iBAAiB,UAAU;AAG7B,QAAI,OAAO,iBAAiB,cAAc,UAAU;AAClD,uBAAiB,YAAY;AAAA,IAC/B;AAAA,EACF;AACF;AAEO,IAAM,YAAY,CACvB,QACA,gBACG,OAAO,aAAa,OAAO,cAAc,CAAC;AAExC,IAAM,gBAAgB,CAC3B,kBAGA,QACA,iBACG,qDAAkB,aAAY,UAAU,QAAQ,WAAW;AAEzD,IAAM,kBAAkB,CAO7B,kBAOA,UACA,uBAEA,SAAS,gBAAgB,gBAAgB,EAAE,MAAM,MAAM;AACrD,qBAAmB,WAAW;AAChC,CAAC;","names":[]}
|
|
@@ -9,6 +9,6 @@ declare const useQueryErrorResetBoundary: () => QueryErrorResetBoundaryValue;
|
|
|
9
9
|
interface QueryErrorResetBoundaryProps {
|
|
10
10
|
children: ((value: QueryErrorResetBoundaryValue) => React.ReactNode) | React.ReactNode;
|
|
11
11
|
}
|
|
12
|
-
declare const QueryErrorResetBoundary: ({ children, }: QueryErrorResetBoundaryProps) => JSX.Element;
|
|
12
|
+
declare const QueryErrorResetBoundary: ({ children, }: QueryErrorResetBoundaryProps) => React.JSX.Element;
|
|
13
13
|
|
|
14
14
|
export { QueryErrorResetBoundary, QueryErrorResetBoundaryProps, QueryErrorResetBoundaryValue, useQueryErrorResetBoundary };
|
|
@@ -9,6 +9,6 @@ declare const useQueryErrorResetBoundary: () => QueryErrorResetBoundaryValue;
|
|
|
9
9
|
interface QueryErrorResetBoundaryProps {
|
|
10
10
|
children: ((value: QueryErrorResetBoundaryValue) => React.ReactNode) | React.ReactNode;
|
|
11
11
|
}
|
|
12
|
-
declare const QueryErrorResetBoundary: ({ children, }: QueryErrorResetBoundaryProps) => JSX.Element;
|
|
12
|
+
declare const QueryErrorResetBoundary: ({ children, }: QueryErrorResetBoundaryProps) => React.JSX.Element;
|
|
13
13
|
|
|
14
14
|
export { QueryErrorResetBoundary, QueryErrorResetBoundaryProps, QueryErrorResetBoundaryValue, useQueryErrorResetBoundary };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/suspense.ts"],"sourcesContent":["import type { DefaultError } from '@tanstack/query-core
|
|
1
|
+
{"version":3,"sources":["../../src/suspense.ts"],"sourcesContent":["import type { DefaultError } from '@tanstack/query-core'\nimport type {\n DefaultedQueryObserverOptions,\n Query,\n QueryKey,\n QueryObserver,\n QueryObserverResult,\n} from '@tanstack/query-core'\nimport type { QueryErrorResetBoundaryValue } from './QueryErrorResetBoundary'\n\nexport const defaultThrowOnError = <\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n _error: TError,\n query: Query<TQueryFnData, TError, TData, TQueryKey>,\n) => typeof query.state.data === 'undefined'\n\nexport const ensureStaleTime = (\n defaultedOptions: DefaultedQueryObserverOptions<any, any, any, any, any>,\n) => {\n if (defaultedOptions.suspense) {\n // Always set stale time when using suspense to prevent\n // fetching again when directly mounting after suspending\n if (typeof defaultedOptions.staleTime !== 'number') {\n defaultedOptions.staleTime = 1000\n }\n }\n}\n\nexport const willFetch = (\n result: QueryObserverResult<any, any>,\n isRestoring: boolean,\n) => result.isLoading && result.isFetching && !isRestoring\n\nexport const shouldSuspend = (\n defaultedOptions:\n | DefaultedQueryObserverOptions<any, any, any, any, any>\n | undefined,\n result: QueryObserverResult<any, any>,\n isRestoring: boolean,\n) => defaultedOptions?.suspense && willFetch(result, isRestoring)\n\nexport const fetchOptimistic = <\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n defaultedOptions: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n observer: QueryObserver<TQueryFnData, TError, TData, TQueryData, TQueryKey>,\n errorResetBoundary: QueryErrorResetBoundaryValue,\n) =>\n observer.fetchOptimistic(defaultedOptions).catch(() => {\n errorResetBoundary.clearReset()\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,IAAM,sBAAsB,CAMjC,QACA,UACG,OAAO,MAAM,MAAM,SAAS;AAE1B,IAAM,kBAAkB,CAC7B,qBACG;AACH,MAAI,iBAAiB,UAAU;AAG7B,QAAI,OAAO,iBAAiB,cAAc,UAAU;AAClD,uBAAiB,YAAY;AAAA,IAC/B;AAAA,EACF;AACF;AAEO,IAAM,YAAY,CACvB,QACA,gBACG,OAAO,aAAa,OAAO,cAAc,CAAC;AAExC,IAAM,gBAAgB,CAC3B,kBAGA,QACA,gBACG,kBAAkB,YAAY,UAAU,QAAQ,WAAW;AAEzD,IAAM,kBAAkB,CAO7B,kBAOA,UACA,uBAEA,SAAS,gBAAgB,gBAAgB,EAAE,MAAM,MAAM;AACrD,qBAAmB,WAAW;AAChC,CAAC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/suspense.ts"],"sourcesContent":["import type { DefaultError } from '@tanstack/query-core
|
|
1
|
+
{"version":3,"sources":["../../src/suspense.ts"],"sourcesContent":["import type { DefaultError } from '@tanstack/query-core'\nimport type {\n DefaultedQueryObserverOptions,\n Query,\n QueryKey,\n QueryObserver,\n QueryObserverResult,\n} from '@tanstack/query-core'\nimport type { QueryErrorResetBoundaryValue } from './QueryErrorResetBoundary'\n\nexport const defaultThrowOnError = <\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n _error: TError,\n query: Query<TQueryFnData, TError, TData, TQueryKey>,\n) => typeof query.state.data === 'undefined'\n\nexport const ensureStaleTime = (\n defaultedOptions: DefaultedQueryObserverOptions<any, any, any, any, any>,\n) => {\n if (defaultedOptions.suspense) {\n // Always set stale time when using suspense to prevent\n // fetching again when directly mounting after suspending\n if (typeof defaultedOptions.staleTime !== 'number') {\n defaultedOptions.staleTime = 1000\n }\n }\n}\n\nexport const willFetch = (\n result: QueryObserverResult<any, any>,\n isRestoring: boolean,\n) => result.isLoading && result.isFetching && !isRestoring\n\nexport const shouldSuspend = (\n defaultedOptions:\n | DefaultedQueryObserverOptions<any, any, any, any, any>\n | undefined,\n result: QueryObserverResult<any, any>,\n isRestoring: boolean,\n) => defaultedOptions?.suspense && willFetch(result, isRestoring)\n\nexport const fetchOptimistic = <\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n defaultedOptions: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n observer: QueryObserver<TQueryFnData, TError, TData, TQueryData, TQueryKey>,\n errorResetBoundary: QueryErrorResetBoundaryValue,\n) =>\n observer.fetchOptimistic(defaultedOptions).catch(() => {\n errorResetBoundary.clearReset()\n })\n"],"mappings":";AAUO,IAAM,sBAAsB,CAMjC,QACA,UACG,OAAO,MAAM,MAAM,SAAS;AAE1B,IAAM,kBAAkB,CAC7B,qBACG;AACH,MAAI,iBAAiB,UAAU;AAG7B,QAAI,OAAO,iBAAiB,cAAc,UAAU;AAClD,uBAAiB,YAAY;AAAA,IAC/B;AAAA,EACF;AACF;AAEO,IAAM,YAAY,CACvB,QACA,gBACG,OAAO,aAAa,OAAO,cAAc,CAAC;AAExC,IAAM,gBAAgB,CAC3B,kBAGA,QACA,gBACG,kBAAkB,YAAY,UAAU,QAAQ,WAAW;AAEzD,IAAM,kBAAkB,CAO7B,kBAOA,UACA,uBAEA,SAAS,gBAAgB,gBAAgB,EAAE,MAAM,MAAM;AACrD,qBAAmB,WAAW;AAChC,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-query",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.3",
|
|
4
4
|
"description": "Hooks for managing, caching and syncing asynchronous and remote data in React",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"!build/codemods/**/__tests__"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@tanstack/query-core": "5.
|
|
44
|
+
"@tanstack/query-core": "5.4.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@types/react": "^18.2.
|
|
48
|
-
"@types/react-dom": "^18.2.
|
|
47
|
+
"@types/react": "^18.2.31",
|
|
48
|
+
"@types/react-dom": "^18.2.14",
|
|
49
49
|
"react": "^18.2.0",
|
|
50
50
|
"react-dom": "^18.2.0",
|
|
51
51
|
"react-error-boundary": "^3.1.4"
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
1
2
|
import { waitFor } from '@testing-library/react'
|
|
2
|
-
import '@testing-library/jest-dom'
|
|
3
3
|
import * as React from 'react'
|
|
4
4
|
import { QueryCache, hashKey } from '@tanstack/query-core'
|
|
5
|
-
import { vi } from 'vitest'
|
|
6
5
|
import { useQuery } from '..'
|
|
7
6
|
import {
|
|
8
7
|
PERSISTER_KEY_PREFIX,
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'
|
|
1
2
|
import * as React from 'react'
|
|
2
3
|
import ReactDOM from 'react-dom'
|
|
3
4
|
import * as ReactDOMTestUtils from 'react-dom/test-utils'
|
|
4
5
|
import * as ReactDOMServer from 'react-dom/server'
|
|
5
|
-
// eslint-disable-next-line import/no-unresolved -- types only for module augmentation
|
|
6
|
-
import type {} from 'react-dom/next'
|
|
7
|
-
import { vi } from 'vitest'
|
|
8
6
|
|
|
9
7
|
import {
|
|
10
8
|
QueryCache,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
1
2
|
import * as React from 'react'
|
|
2
3
|
// @ts-ignore
|
|
3
4
|
import { renderToString } from 'react-dom/server'
|
|
4
|
-
|
|
5
|
-
import { vi } from 'vitest'
|
|
6
5
|
import { QueryCache, QueryClientProvider, useInfiniteQuery, useQuery } from '..'
|
|
7
6
|
import { createQueryClient, queryKey, sleep } from './utils'
|
|
8
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
1
2
|
import { fireEvent, waitFor } from '@testing-library/react'
|
|
2
3
|
import * as React from 'react'
|
|
3
4
|
import { ErrorBoundary } from 'react-error-boundary'
|
|
4
|
-
import { vi } from 'vitest'
|
|
5
5
|
import {
|
|
6
6
|
QueryCache,
|
|
7
7
|
QueryErrorResetBoundary,
|
|
@@ -816,7 +816,7 @@ describe('useSuspenseQueries', () => {
|
|
|
816
816
|
})
|
|
817
817
|
return (
|
|
818
818
|
<div>
|
|
819
|
-
<h1>data: {result.map((
|
|
819
|
+
<h1>data: {result.map((item) => item.data ?? 'null').join(',')}</h1>
|
|
820
820
|
</div>
|
|
821
821
|
)
|
|
822
822
|
}
|
|
@@ -871,7 +871,7 @@ describe('useSuspenseQueries', () => {
|
|
|
871
871
|
})
|
|
872
872
|
return (
|
|
873
873
|
<div>
|
|
874
|
-
<h1>data: {result.map((
|
|
874
|
+
<h1>data: {result.map((item) => item.data ?? 'null').join(',')}</h1>
|
|
875
875
|
</div>
|
|
876
876
|
)
|
|
877
877
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
1
2
|
import { fireEvent, render, waitFor } from '@testing-library/react'
|
|
2
3
|
import * as React from 'react'
|
|
3
|
-
|
|
4
|
-
import { vi } from 'vitest'
|
|
5
4
|
import { QueryCache, keepPreviousData, useInfiniteQuery } from '..'
|
|
6
5
|
import {
|
|
7
6
|
createQueryClient,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
1
2
|
import { fireEvent, render, waitFor } from '@testing-library/react'
|
|
2
|
-
import '@testing-library/jest-dom'
|
|
3
3
|
import * as React from 'react'
|
|
4
4
|
import { ErrorBoundary } from 'react-error-boundary'
|
|
5
|
-
|
|
6
|
-
import { vi } from 'vitest'
|
|
7
5
|
import { MutationCache, QueryCache, useMutation } from '..'
|
|
8
6
|
import {
|
|
9
7
|
createQueryClient,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { describe, expect, expectTypeOf, it, vi } from 'vitest'
|
|
1
2
|
import { fireEvent, render, waitFor } from '@testing-library/react'
|
|
2
3
|
import * as React from 'react'
|
|
3
4
|
import { ErrorBoundary } from 'react-error-boundary'
|
|
4
|
-
|
|
5
|
-
import { vi } from 'vitest'
|
|
6
5
|
import { QueryCache, useQueries } from '..'
|
|
7
6
|
import {
|
|
8
7
|
createQueryClient,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { describe, expect, expectTypeOf, it, test, vi } from 'vitest'
|
|
1
2
|
import { act, fireEvent, render, waitFor } from '@testing-library/react'
|
|
2
|
-
import '@testing-library/jest-dom'
|
|
3
3
|
import * as React from 'react'
|
|
4
4
|
import { ErrorBoundary } from 'react-error-boundary'
|
|
5
|
-
import { vi } from 'vitest'
|
|
6
5
|
import { QueryCache, keepPreviousData, useQuery } from '..'
|
|
7
6
|
import {
|
|
8
7
|
Blink,
|
|
@@ -154,8 +153,8 @@ describe('useQuery', () => {
|
|
|
154
153
|
queryFn: () => fetcher(qk[1], 'token'),
|
|
155
154
|
...options,
|
|
156
155
|
})
|
|
157
|
-
const
|
|
158
|
-
expectTypeOf<string | undefined>(
|
|
156
|
+
const testQuery = useWrappedQuery([''], async () => '1')
|
|
157
|
+
expectTypeOf<string | undefined>(testQuery.data)
|
|
159
158
|
|
|
160
159
|
// handles wrapped queries with custom fetcher passed directly to useQuery
|
|
161
160
|
const useWrappedFuncStyleQuery = <
|
package/src/__tests__/utils.tsx
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { vi } from 'vitest'
|
|
1
2
|
import * as React from 'react'
|
|
2
3
|
import { act, render } from '@testing-library/react'
|
|
3
|
-
|
|
4
4
|
import * as utils from '@tanstack/query-core'
|
|
5
|
-
import { vi } from 'vitest'
|
|
6
5
|
import { QueryClient, QueryClientProvider, onlineManager } from '..'
|
|
7
6
|
import type { QueryClientConfig } from '..'
|
|
8
7
|
import type { SpyInstance } from 'vitest'
|
package/src/suspense.ts
CHANGED