@tanstack/react-query 4.24.10 → 5.0.0-alpha.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.
- package/build/lib/HydrationBoundary.d.ts +9 -0
- package/build/lib/{Hydrate.esm.js → HydrationBoundary.esm.js} +14 -17
- package/build/lib/HydrationBoundary.esm.js.map +1 -0
- package/build/lib/{Hydrate.js → HydrationBoundary.js} +17 -24
- package/build/lib/HydrationBoundary.js.map +1 -0
- package/build/lib/{Hydrate.mjs → HydrationBoundary.mjs} +14 -17
- package/build/lib/HydrationBoundary.mjs.map +1 -0
- package/build/lib/QueryClientProvider.d.ts +4 -19
- package/build/lib/QueryClientProvider.esm.js +11 -46
- package/build/lib/QueryClientProvider.esm.js.map +1 -1
- package/build/lib/QueryClientProvider.js +14 -52
- package/build/lib/QueryClientProvider.js.map +1 -1
- package/build/lib/QueryClientProvider.mjs +11 -46
- package/build/lib/QueryClientProvider.mjs.map +1 -1
- package/build/lib/QueryErrorResetBoundary.esm.js +7 -2
- package/build/lib/QueryErrorResetBoundary.esm.js.map +1 -1
- package/build/lib/QueryErrorResetBoundary.js +10 -8
- package/build/lib/QueryErrorResetBoundary.js.map +1 -1
- package/build/lib/QueryErrorResetBoundary.mjs +7 -2
- package/build/lib/QueryErrorResetBoundary.mjs.map +1 -1
- package/build/lib/__tests__/useQuery.types.test.d.ts +1 -2
- package/build/lib/__tests__/utils.d.ts +7 -10
- package/build/lib/errorBoundaryUtils.d.ts +3 -3
- package/build/lib/errorBoundaryUtils.esm.js +3 -3
- package/build/lib/errorBoundaryUtils.esm.js.map +1 -1
- package/build/lib/errorBoundaryUtils.js +6 -9
- package/build/lib/errorBoundaryUtils.js.map +1 -1
- package/build/lib/errorBoundaryUtils.mjs +3 -3
- package/build/lib/errorBoundaryUtils.mjs.map +1 -1
- package/build/lib/index.d.ts +4 -5
- package/build/lib/index.esm.js +3 -4
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +6 -9
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +3 -4
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/isRestoring.esm.js.map +1 -1
- package/build/lib/isRestoring.js +3 -6
- package/build/lib/isRestoring.js.map +1 -1
- package/build/lib/isRestoring.mjs.map +1 -1
- package/build/lib/suspense.esm.js +5 -5
- package/build/lib/suspense.esm.js.map +1 -1
- package/build/lib/suspense.js +5 -7
- package/build/lib/suspense.js.map +1 -1
- package/build/lib/suspense.mjs +5 -5
- package/build/lib/suspense.mjs.map +1 -1
- package/build/lib/types.d.ts +14 -22
- package/build/lib/useBaseQuery.d.ts +2 -2
- package/build/lib/useBaseQuery.esm.js +15 -18
- package/build/lib/useBaseQuery.esm.js.map +1 -1
- package/build/lib/useBaseQuery.js +18 -24
- package/build/lib/useBaseQuery.js.map +1 -1
- package/build/lib/useBaseQuery.mjs +15 -18
- package/build/lib/useBaseQuery.mjs.map +1 -1
- package/build/lib/useInfiniteQuery.d.ts +2 -4
- package/build/lib/useInfiniteQuery.esm.js +4 -4
- package/build/lib/useInfiniteQuery.esm.js.map +1 -1
- package/build/lib/useInfiniteQuery.js +3 -5
- package/build/lib/useInfiniteQuery.js.map +1 -1
- package/build/lib/useInfiniteQuery.mjs +4 -4
- package/build/lib/useInfiniteQuery.mjs.map +1 -1
- package/build/lib/useIsFetching.d.ts +2 -7
- package/build/lib/useIsFetching.esm.js +5 -9
- package/build/lib/useIsFetching.esm.js.map +1 -1
- package/build/lib/useIsFetching.js +7 -14
- package/build/lib/useIsFetching.js.map +1 -1
- package/build/lib/useIsFetching.mjs +5 -9
- package/build/lib/useIsFetching.mjs.map +1 -1
- package/build/lib/useMutation.d.ts +2 -5
- package/build/lib/useMutation.esm.js +12 -14
- package/build/lib/useMutation.esm.js.map +1 -1
- package/build/lib/useMutation.js +14 -19
- package/build/lib/useMutation.js.map +1 -1
- package/build/lib/useMutation.mjs +12 -14
- package/build/lib/useMutation.mjs.map +1 -1
- package/build/lib/useMutationState.d.ts +8 -0
- package/build/lib/useMutationState.esm.js +37 -0
- package/build/lib/useMutationState.esm.js.map +1 -0
- package/build/lib/useMutationState.js +59 -0
- package/build/lib/useMutationState.js.map +1 -0
- package/build/lib/useMutationState.mjs +37 -0
- package/build/lib/useMutationState.mjs.map +1 -0
- package/build/lib/useQueries.d.ts +9 -7
- package/build/lib/useQueries.esm.js +16 -27
- package/build/lib/useQueries.esm.js.map +1 -1
- package/build/lib/useQueries.js +19 -33
- package/build/lib/useQueries.js.map +1 -1
- package/build/lib/useQueries.mjs +16 -27
- package/build/lib/useQueries.mjs.map +1 -1
- package/build/lib/useQuery.d.ts +9 -21
- package/build/lib/useQuery.esm.js +5 -4
- package/build/lib/useQuery.esm.js.map +1 -1
- package/build/lib/useQuery.js +4 -5
- package/build/lib/useQuery.js.map +1 -1
- package/build/lib/useQuery.mjs +5 -4
- package/build/lib/useQuery.mjs.map +1 -1
- package/build/lib/utils.d.ts +1 -1
- package/build/lib/utils.esm.js +5 -6
- package/build/lib/utils.esm.js.map +1 -1
- package/build/lib/utils.js +5 -8
- package/build/lib/utils.js.map +1 -1
- package/build/lib/utils.mjs +5 -6
- package/build/lib/utils.mjs.map +1 -1
- package/build/umd/index.development.js +1003 -1827
- 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 +6 -18
- package/src/{Hydrate.tsx → HydrationBoundary.tsx} +17 -18
- package/src/QueryClientProvider.tsx +11 -65
- package/src/__tests__/{Hydrate.test.tsx → HydrationBoundary.test.tsx} +89 -77
- package/src/__tests__/QueryClientProvider.test.tsx +33 -147
- package/src/__tests__/QueryResetErrorBoundary.test.tsx +118 -85
- package/src/__tests__/ssr-hydration.test.tsx +27 -33
- package/src/__tests__/ssr.test.tsx +23 -9
- package/src/__tests__/suspense.test.tsx +194 -171
- package/src/__tests__/useInfiniteQuery.test.tsx +249 -494
- package/src/__tests__/useInfiniteQuery.type.test.tsx +131 -0
- package/src/__tests__/useIsFetching.test.tsx +65 -108
- package/src/__tests__/useMutation.test.tsx +200 -268
- package/src/__tests__/useMutationState.test.tsx +284 -0
- package/src/__tests__/useQueries.test.tsx +43 -347
- package/src/__tests__/useQuery.test.tsx +890 -686
- package/src/__tests__/useQuery.types.test.tsx +23 -24
- package/src/__tests__/utils.tsx +14 -23
- package/src/errorBoundaryUtils.ts +5 -10
- package/src/index.ts +4 -7
- package/src/types.ts +33 -38
- package/src/useBaseQuery.ts +7 -7
- package/src/useInfiniteQuery.ts +12 -77
- package/src/useIsFetching.ts +8 -20
- package/src/useMutation.ts +8 -66
- package/src/useMutationState.ts +81 -0
- package/src/useQueries.ts +29 -21
- package/src/useQuery.ts +27 -104
- package/src/utils.ts +5 -5
- package/build/lib/Hydrate.d.ts +0 -10
- package/build/lib/Hydrate.esm.js.map +0 -1
- package/build/lib/Hydrate.js.map +0 -1
- package/build/lib/Hydrate.mjs.map +0 -1
- package/build/lib/reactBatchedUpdates.d.ts +0 -2
- package/build/lib/reactBatchedUpdates.esm.js +0 -6
- package/build/lib/reactBatchedUpdates.esm.js.map +0 -1
- package/build/lib/reactBatchedUpdates.js +0 -30
- package/build/lib/reactBatchedUpdates.js.map +0 -1
- package/build/lib/reactBatchedUpdates.mjs +0 -6
- package/build/lib/reactBatchedUpdates.mjs.map +0 -1
- package/build/lib/reactBatchedUpdates.native.d.ts +0 -2
- package/build/lib/reactBatchedUpdates.native.esm.js +0 -2
- package/build/lib/reactBatchedUpdates.native.esm.js.map +0 -1
- package/build/lib/reactBatchedUpdates.native.js +0 -13
- package/build/lib/reactBatchedUpdates.native.js.map +0 -1
- package/build/lib/reactBatchedUpdates.native.mjs +0 -2
- package/build/lib/reactBatchedUpdates.native.mjs.map +0 -1
- package/build/lib/setBatchUpdatesFn.esm.js +0 -5
- package/build/lib/setBatchUpdatesFn.esm.js.map +0 -1
- package/build/lib/setBatchUpdatesFn.js +0 -7
- package/build/lib/setBatchUpdatesFn.js.map +0 -1
- package/build/lib/setBatchUpdatesFn.mjs +0 -5
- package/build/lib/setBatchUpdatesFn.mjs.map +0 -1
- package/build/lib/useIsMutating.d.ts +0 -7
- package/build/lib/useIsMutating.esm.js +0 -16
- package/build/lib/useIsMutating.esm.js.map +0 -1
- package/build/lib/useIsMutating.js +0 -40
- package/build/lib/useIsMutating.js.map +0 -1
- package/build/lib/useIsMutating.mjs +0 -16
- package/build/lib/useIsMutating.mjs.map +0 -1
- package/build/lib/useSyncExternalStore.d.ts +0 -2
- package/build/lib/useSyncExternalStore.esm.js +0 -7
- package/build/lib/useSyncExternalStore.esm.js.map +0 -1
- package/build/lib/useSyncExternalStore.js +0 -11
- package/build/lib/useSyncExternalStore.js.map +0 -1
- package/build/lib/useSyncExternalStore.mjs +0 -7
- package/build/lib/useSyncExternalStore.mjs.map +0 -1
- package/build/lib/useSyncExternalStore.native.d.ts +0 -2
- package/build/lib/useSyncExternalStore.native.esm.js +0 -2
- package/build/lib/useSyncExternalStore.native.esm.js.map +0 -1
- package/build/lib/useSyncExternalStore.native.js +0 -13
- package/build/lib/useSyncExternalStore.native.js.map +0 -1
- package/build/lib/useSyncExternalStore.native.mjs +0 -2
- package/build/lib/useSyncExternalStore.native.mjs.map +0 -1
- package/codemods/v4/key-transformation.js +0 -138
- package/codemods/v4/replace-import-specifier.js +0 -25
- package/codemods/v4/utils/index.js +0 -166
- package/codemods/v4/utils/replacers/key-replacer.js +0 -160
- package/codemods/v4/utils/transformers/query-cache-transformer.js +0 -115
- package/codemods/v4/utils/transformers/query-client-transformer.js +0 -49
- package/codemods/v4/utils/transformers/use-query-like-transformer.js +0 -32
- package/codemods/v4/utils/unprocessable-key-error.js +0 -8
- package/src/__tests__/useIsMutating.test.tsx +0 -259
- package/src/reactBatchedUpdates.native.ts +0 -4
- package/src/reactBatchedUpdates.ts +0 -2
- package/src/setBatchUpdatesFn.ts +0 -4
- package/src/useIsMutating.ts +0 -39
- package/src/useSyncExternalStore.native.ts +0 -5
- package/src/useSyncExternalStore.ts +0 -4
- /package/build/lib/__tests__/{Hydrate.test.d.ts → HydrationBoundary.test.d.ts} +0 -0
- /package/build/lib/__tests__/{useIsMutating.test.d.ts → useInfiniteQuery.type.test.d.ts} +0 -0
- /package/build/lib/{setBatchUpdatesFn.d.ts → __tests__/useMutationState.test.d.ts} +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { HydrateOptions, QueryClient } from '@tanstack/query-core';
|
|
3
|
+
export interface HydrationBoundaryProps {
|
|
4
|
+
state?: unknown;
|
|
5
|
+
options?: HydrateOptions;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
queryClient?: QueryClient;
|
|
8
|
+
}
|
|
9
|
+
export declare const HydrationBoundary: ({ children, options, state, queryClient, }: HydrationBoundaryProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
@@ -2,30 +2,27 @@ import * as React from 'react';
|
|
|
2
2
|
import { hydrate } from '@tanstack/query-core';
|
|
3
3
|
import { useQueryClient } from './QueryClientProvider.esm.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const HydrationBoundary = ({
|
|
6
|
+
children,
|
|
7
|
+
options = {},
|
|
8
|
+
state,
|
|
9
|
+
queryClient
|
|
10
|
+
}) => {
|
|
11
|
+
const client = useQueryClient(queryClient);
|
|
9
12
|
const optionsRef = React.useRef(options);
|
|
10
|
-
optionsRef.current = options;
|
|
13
|
+
optionsRef.current = options;
|
|
14
|
+
|
|
15
|
+
// Running hydrate again with the same queries is safe,
|
|
11
16
|
// it wont overwrite or initialize existing queries,
|
|
12
17
|
// relying on useMemo here is only a performance optimization.
|
|
13
18
|
// hydrate can and should be run *during* render here for SSR to work properly
|
|
14
|
-
|
|
15
19
|
React.useMemo(() => {
|
|
16
20
|
if (state) {
|
|
17
|
-
hydrate(
|
|
21
|
+
hydrate(client, state, optionsRef.current);
|
|
18
22
|
}
|
|
19
|
-
}, [
|
|
20
|
-
}
|
|
21
|
-
const Hydrate = ({
|
|
22
|
-
children,
|
|
23
|
-
options,
|
|
24
|
-
state
|
|
25
|
-
}) => {
|
|
26
|
-
useHydrate(state, options);
|
|
23
|
+
}, [client, state]);
|
|
27
24
|
return children;
|
|
28
25
|
};
|
|
29
26
|
|
|
30
|
-
export {
|
|
31
|
-
//# sourceMappingURL=
|
|
27
|
+
export { HydrationBoundary };
|
|
28
|
+
//# sourceMappingURL=HydrationBoundary.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HydrationBoundary.esm.js","sources":["../../src/HydrationBoundary.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { HydrateOptions, QueryClient } from '@tanstack/query-core'\nimport { hydrate } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\n\nexport interface HydrationBoundaryProps {\n state?: unknown\n options?: HydrateOptions\n children?: React.ReactNode\n queryClient?: QueryClient\n}\n\nexport const HydrationBoundary = ({\n children,\n options = {},\n state,\n queryClient,\n}: HydrationBoundaryProps) => {\n const client = useQueryClient(queryClient)\n\n const optionsRef = React.useRef(options)\n optionsRef.current = options\n\n // Running hydrate again with the same queries is safe,\n // it wont overwrite or initialize existing queries,\n // relying on useMemo here is only a performance optimization.\n // hydrate can and should be run *during* render here for SSR to work properly\n React.useMemo(() => {\n if (state) {\n hydrate(client, state, optionsRef.current)\n }\n }, [client, state])\n\n return children as React.ReactElement\n}\n"],"names":["HydrationBoundary","children","options","state","queryClient","client","useQueryClient","optionsRef","React","useRef","current","useMemo","hydrate"],"mappings":";;;;AAcO,MAAMA,iBAAiB,GAAG,CAAC;EAChCC,QAAQ;EACRC,OAAO,GAAG,EAAE;EACZC,KAAK;AACLC,EAAAA,WAAAA;AACsB,CAAC,KAAK;AAC5B,EAAA,MAAMC,MAAM,GAAGC,cAAc,CAACF,WAAW,CAAC,CAAA;AAE1C,EAAA,MAAMG,UAAU,GAAGC,KAAK,CAACC,MAAM,CAACP,OAAO,CAAC,CAAA;EACxCK,UAAU,CAACG,OAAO,GAAGR,OAAO,CAAA;;AAE5B;AACA;AACA;AACA;EACAM,KAAK,CAACG,OAAO,CAAC,MAAM;AAClB,IAAA,IAAIR,KAAK,EAAE;MACTS,OAAO,CAACP,MAAM,EAAEF,KAAK,EAAEI,UAAU,CAACG,OAAO,CAAC,CAAA;AAC5C,KAAA;AACF,GAAC,EAAE,CAACL,MAAM,EAAEF,KAAK,CAAC,CAAC,CAAA;AAEnB,EAAA,OAAOF,QAAQ,CAAA;AACjB;;;;"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var React = require('react');
|
|
6
4
|
var queryCore = require('@tanstack/query-core');
|
|
7
5
|
var QueryClientProvider = require('./QueryClientProvider.js');
|
|
8
6
|
|
|
9
|
-
function
|
|
10
|
-
if (e && e.__esModule) return e;
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
11
8
|
var n = Object.create(null);
|
|
12
9
|
if (e) {
|
|
13
10
|
Object.keys(e).forEach(function (k) {
|
|
@@ -20,37 +17,33 @@ function _interopNamespace(e) {
|
|
|
20
17
|
}
|
|
21
18
|
});
|
|
22
19
|
}
|
|
23
|
-
n
|
|
20
|
+
n.default = e;
|
|
24
21
|
return Object.freeze(n);
|
|
25
22
|
}
|
|
26
23
|
|
|
27
|
-
var React__namespace = /*#__PURE__*/
|
|
24
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
const HydrationBoundary = ({
|
|
27
|
+
children,
|
|
28
|
+
options = {},
|
|
29
|
+
state,
|
|
30
|
+
queryClient
|
|
31
|
+
}) => {
|
|
32
|
+
const client = QueryClientProvider.useQueryClient(queryClient);
|
|
33
33
|
const optionsRef = React__namespace.useRef(options);
|
|
34
|
-
optionsRef.current = options;
|
|
34
|
+
optionsRef.current = options;
|
|
35
|
+
|
|
36
|
+
// Running hydrate again with the same queries is safe,
|
|
35
37
|
// it wont overwrite or initialize existing queries,
|
|
36
38
|
// relying on useMemo here is only a performance optimization.
|
|
37
39
|
// hydrate can and should be run *during* render here for SSR to work properly
|
|
38
|
-
|
|
39
40
|
React__namespace.useMemo(() => {
|
|
40
41
|
if (state) {
|
|
41
|
-
queryCore.hydrate(
|
|
42
|
+
queryCore.hydrate(client, state, optionsRef.current);
|
|
42
43
|
}
|
|
43
|
-
}, [
|
|
44
|
-
}
|
|
45
|
-
const Hydrate = ({
|
|
46
|
-
children,
|
|
47
|
-
options,
|
|
48
|
-
state
|
|
49
|
-
}) => {
|
|
50
|
-
useHydrate(state, options);
|
|
44
|
+
}, [client, state]);
|
|
51
45
|
return children;
|
|
52
46
|
};
|
|
53
47
|
|
|
54
|
-
exports.
|
|
55
|
-
|
|
56
|
-
//# sourceMappingURL=Hydrate.js.map
|
|
48
|
+
exports.HydrationBoundary = HydrationBoundary;
|
|
49
|
+
//# sourceMappingURL=HydrationBoundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HydrationBoundary.js","sources":["../../src/HydrationBoundary.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { HydrateOptions, QueryClient } from '@tanstack/query-core'\nimport { hydrate } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\n\nexport interface HydrationBoundaryProps {\n state?: unknown\n options?: HydrateOptions\n children?: React.ReactNode\n queryClient?: QueryClient\n}\n\nexport const HydrationBoundary = ({\n children,\n options = {},\n state,\n queryClient,\n}: HydrationBoundaryProps) => {\n const client = useQueryClient(queryClient)\n\n const optionsRef = React.useRef(options)\n optionsRef.current = options\n\n // Running hydrate again with the same queries is safe,\n // it wont overwrite or initialize existing queries,\n // relying on useMemo here is only a performance optimization.\n // hydrate can and should be run *during* render here for SSR to work properly\n React.useMemo(() => {\n if (state) {\n hydrate(client, state, optionsRef.current)\n }\n }, [client, state])\n\n return children as React.ReactElement\n}\n"],"names":["HydrationBoundary","children","options","state","queryClient","client","useQueryClient","optionsRef","React","useRef","current","useMemo","hydrate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAcO,MAAMA,iBAAiB,GAAG,CAAC;EAChCC,QAAQ;EACRC,OAAO,GAAG,EAAE;EACZC,KAAK;AACLC,EAAAA,WAAAA;AACsB,CAAC,KAAK;AAC5B,EAAA,MAAMC,MAAM,GAAGC,kCAAc,CAACF,WAAW,CAAC,CAAA;AAE1C,EAAA,MAAMG,UAAU,GAAGC,gBAAK,CAACC,MAAM,CAACP,OAAO,CAAC,CAAA;EACxCK,UAAU,CAACG,OAAO,GAAGR,OAAO,CAAA;;AAE5B;AACA;AACA;AACA;EACAM,gBAAK,CAACG,OAAO,CAAC,MAAM;AAClB,IAAA,IAAIR,KAAK,EAAE;MACTS,iBAAO,CAACP,MAAM,EAAEF,KAAK,EAAEI,UAAU,CAACG,OAAO,CAAC,CAAA;AAC5C,KAAA;AACF,GAAC,EAAE,CAACL,MAAM,EAAEF,KAAK,CAAC,CAAC,CAAA;AAEnB,EAAA,OAAOF,QAAQ,CAAA;AACjB;;;;"}
|
|
@@ -2,30 +2,27 @@ import * as React from 'react';
|
|
|
2
2
|
import { hydrate } from '@tanstack/query-core';
|
|
3
3
|
import { useQueryClient } from './QueryClientProvider.mjs';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const HydrationBoundary = ({
|
|
6
|
+
children,
|
|
7
|
+
options = {},
|
|
8
|
+
state,
|
|
9
|
+
queryClient
|
|
10
|
+
}) => {
|
|
11
|
+
const client = useQueryClient(queryClient);
|
|
9
12
|
const optionsRef = React.useRef(options);
|
|
10
|
-
optionsRef.current = options;
|
|
13
|
+
optionsRef.current = options;
|
|
14
|
+
|
|
15
|
+
// Running hydrate again with the same queries is safe,
|
|
11
16
|
// it wont overwrite or initialize existing queries,
|
|
12
17
|
// relying on useMemo here is only a performance optimization.
|
|
13
18
|
// hydrate can and should be run *during* render here for SSR to work properly
|
|
14
|
-
|
|
15
19
|
React.useMemo(() => {
|
|
16
20
|
if (state) {
|
|
17
|
-
hydrate(
|
|
21
|
+
hydrate(client, state, optionsRef.current);
|
|
18
22
|
}
|
|
19
|
-
}, [
|
|
20
|
-
}
|
|
21
|
-
const Hydrate = ({
|
|
22
|
-
children,
|
|
23
|
-
options,
|
|
24
|
-
state
|
|
25
|
-
}) => {
|
|
26
|
-
useHydrate(state, options);
|
|
23
|
+
}, [client, state]);
|
|
27
24
|
return children;
|
|
28
25
|
};
|
|
29
26
|
|
|
30
|
-
export {
|
|
31
|
-
//# sourceMappingURL=
|
|
27
|
+
export { HydrationBoundary };
|
|
28
|
+
//# sourceMappingURL=HydrationBoundary.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HydrationBoundary.mjs","sources":["../../src/HydrationBoundary.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { HydrateOptions, QueryClient } from '@tanstack/query-core'\nimport { hydrate } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\n\nexport interface HydrationBoundaryProps {\n state?: unknown\n options?: HydrateOptions\n children?: React.ReactNode\n queryClient?: QueryClient\n}\n\nexport const HydrationBoundary = ({\n children,\n options = {},\n state,\n queryClient,\n}: HydrationBoundaryProps) => {\n const client = useQueryClient(queryClient)\n\n const optionsRef = React.useRef(options)\n optionsRef.current = options\n\n // Running hydrate again with the same queries is safe,\n // it wont overwrite or initialize existing queries,\n // relying on useMemo here is only a performance optimization.\n // hydrate can and should be run *during* render here for SSR to work properly\n React.useMemo(() => {\n if (state) {\n hydrate(client, state, optionsRef.current)\n }\n }, [client, state])\n\n return children as React.ReactElement\n}\n"],"names":["HydrationBoundary","children","options","state","queryClient","client","useQueryClient","optionsRef","React","useRef","current","useMemo","hydrate"],"mappings":";;;;AAcO,MAAMA,iBAAiB,GAAG,CAAC;EAChCC,QAAQ;EACRC,OAAO,GAAG,EAAE;EACZC,KAAK;AACLC,EAAAA,WAAAA;AACsB,CAAC,KAAK;AAC5B,EAAA,MAAMC,MAAM,GAAGC,cAAc,CAACF,WAAW,CAAC,CAAA;AAE1C,EAAA,MAAMG,UAAU,GAAGC,KAAK,CAACC,MAAM,CAACP,OAAO,CAAC,CAAA;EACxCK,UAAU,CAACG,OAAO,GAAGR,OAAO,CAAA;;AAE5B;AACA;AACA;AACA;EACAM,KAAK,CAACG,OAAO,CAAC,MAAM;AAClB,IAAA,IAAIR,KAAK,EAAE;MACTS,OAAO,CAACP,MAAM,EAAEF,KAAK,EAAEI,UAAU,CAACG,OAAO,CAAC,CAAA;AAC5C,KAAA;AACF,GAAC,EAAE,CAACL,MAAM,EAAEF,KAAK,CAAC,CAAC,CAAA;AAEnB,EAAA,OAAOF,QAAQ,CAAA;AACjB;;;;"}
|
|
@@ -1,24 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { QueryClient } from '@tanstack/query-core';
|
|
3
|
-
|
|
4
|
-
declare
|
|
5
|
-
|
|
6
|
-
ReactQueryClientContext?: React.Context<QueryClient | undefined>;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export declare const defaultContext: React.Context<QueryClient | undefined>;
|
|
10
|
-
export declare const useQueryClient: ({ context }?: ContextOptions) => QueryClient;
|
|
11
|
-
declare type QueryClientProviderPropsBase = {
|
|
3
|
+
export declare const QueryClientContext: React.Context<QueryClient | undefined>;
|
|
4
|
+
export declare const useQueryClient: (queryClient?: QueryClient) => QueryClient;
|
|
5
|
+
export declare type QueryClientProviderProps = {
|
|
12
6
|
client: QueryClient;
|
|
13
7
|
children?: React.ReactNode;
|
|
14
8
|
};
|
|
15
|
-
declare
|
|
16
|
-
contextSharing?: never;
|
|
17
|
-
} & QueryClientProviderPropsBase;
|
|
18
|
-
declare type QueryClientProviderPropsWithContextSharing = {
|
|
19
|
-
context?: never;
|
|
20
|
-
contextSharing?: boolean;
|
|
21
|
-
} & QueryClientProviderPropsBase;
|
|
22
|
-
export declare type QueryClientProviderProps = QueryClientProviderPropsWithContext | QueryClientProviderPropsWithContextSharing;
|
|
23
|
-
export declare const QueryClientProvider: ({ client, children, context, contextSharing, }: QueryClientProviderProps) => JSX.Element;
|
|
24
|
-
export {};
|
|
9
|
+
export declare const QueryClientProvider: ({ client, children, }: QueryClientProviderProps) => JSX.Element;
|
|
@@ -1,46 +1,19 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// different bundles or microfrontends they will
|
|
9
|
-
// all use the same **instance** of context, regardless
|
|
10
|
-
// of module scoping.
|
|
11
|
-
|
|
12
|
-
function getQueryClientContext(context, contextSharing) {
|
|
13
|
-
if (context) {
|
|
14
|
-
return context;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (contextSharing && typeof window !== 'undefined') {
|
|
18
|
-
if (!window.ReactQueryClientContext) {
|
|
19
|
-
window.ReactQueryClientContext = defaultContext;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return window.ReactQueryClientContext;
|
|
3
|
+
const QueryClientContext = /*#__PURE__*/React.createContext(undefined);
|
|
4
|
+
const useQueryClient = queryClient => {
|
|
5
|
+
const client = React.useContext(QueryClientContext);
|
|
6
|
+
if (queryClient) {
|
|
7
|
+
return queryClient;
|
|
23
8
|
}
|
|
24
|
-
|
|
25
|
-
return defaultContext;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const useQueryClient = ({
|
|
29
|
-
context
|
|
30
|
-
} = {}) => {
|
|
31
|
-
const queryClient = React.useContext(getQueryClientContext(context, React.useContext(QueryClientSharingContext)));
|
|
32
|
-
|
|
33
|
-
if (!queryClient) {
|
|
9
|
+
if (!client) {
|
|
34
10
|
throw new Error('No QueryClient set, use QueryClientProvider to set one');
|
|
35
11
|
}
|
|
36
|
-
|
|
37
|
-
return queryClient;
|
|
12
|
+
return client;
|
|
38
13
|
};
|
|
39
14
|
const QueryClientProvider = ({
|
|
40
15
|
client,
|
|
41
|
-
children
|
|
42
|
-
context,
|
|
43
|
-
contextSharing = false
|
|
16
|
+
children
|
|
44
17
|
}) => {
|
|
45
18
|
React.useEffect(() => {
|
|
46
19
|
client.mount();
|
|
@@ -48,18 +21,10 @@ const QueryClientProvider = ({
|
|
|
48
21
|
client.unmount();
|
|
49
22
|
};
|
|
50
23
|
}, [client]);
|
|
51
|
-
|
|
52
|
-
if (process.env.NODE_ENV !== 'production' && contextSharing) {
|
|
53
|
-
client.getLogger().error("The contextSharing option has been deprecated and will be removed in the next major version");
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const Context = getQueryClientContext(context, contextSharing);
|
|
57
|
-
return /*#__PURE__*/React.createElement(QueryClientSharingContext.Provider, {
|
|
58
|
-
value: !context && contextSharing
|
|
59
|
-
}, /*#__PURE__*/React.createElement(Context.Provider, {
|
|
24
|
+
return /*#__PURE__*/React.createElement(QueryClientContext.Provider, {
|
|
60
25
|
value: client
|
|
61
|
-
}, children)
|
|
26
|
+
}, children);
|
|
62
27
|
};
|
|
63
28
|
|
|
64
|
-
export {
|
|
29
|
+
export { QueryClientContext, QueryClientProvider, useQueryClient };
|
|
65
30
|
//# sourceMappingURL=QueryClientProvider.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClientProvider.esm.js","sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\
|
|
1
|
+
{"version":3,"file":"QueryClientProvider.esm.js","sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\n\nexport const QueryClientContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\n\nexport const useQueryClient = (queryClient?: QueryClient) => {\n const client = React.useContext(QueryClientContext)\n\n if (queryClient) {\n return queryClient\n }\n\n if (!client) {\n throw new Error('No QueryClient set, use QueryClientProvider to set one')\n }\n\n return client\n}\n\nexport type QueryClientProviderProps = {\n client: QueryClient\n children?: React.ReactNode\n}\n\nexport const QueryClientProvider = ({\n client,\n children,\n}: QueryClientProviderProps): JSX.Element => {\n React.useEffect(() => {\n client.mount()\n return () => {\n client.unmount()\n }\n }, [client])\n\n return (\n <QueryClientContext.Provider value={client}>\n {children}\n </QueryClientContext.Provider>\n )\n}\n"],"names":["QueryClientContext","React","createContext","undefined","useQueryClient","queryClient","client","useContext","Error","QueryClientProvider","children","useEffect","mount","unmount"],"mappings":";;AAKO,MAAMA,kBAAkB,gBAAGC,KAAK,CAACC,aAAa,CACnDC,SAAS,EACV;AAEYC,MAAAA,cAAc,GAAIC,WAAyB,IAAK;AAC3D,EAAA,MAAMC,MAAM,GAAGL,KAAK,CAACM,UAAU,CAACP,kBAAkB,CAAC,CAAA;AAEnD,EAAA,IAAIK,WAAW,EAAE;AACf,IAAA,OAAOA,WAAW,CAAA;AACpB,GAAA;EAEA,IAAI,CAACC,MAAM,EAAE;AACX,IAAA,MAAM,IAAIE,KAAK,CAAC,wDAAwD,CAAC,CAAA;AAC3E,GAAA;AAEA,EAAA,OAAOF,MAAM,CAAA;AACf,EAAC;AAOM,MAAMG,mBAAmB,GAAG,CAAC;EAClCH,MAAM;AACNI,EAAAA,QAAAA;AACwB,CAAC,KAAkB;EAC3CT,KAAK,CAACU,SAAS,CAAC,MAAM;IACpBL,MAAM,CAACM,KAAK,EAAE,CAAA;AACd,IAAA,OAAO,MAAM;MACXN,MAAM,CAACO,OAAO,EAAE,CAAA;KACjB,CAAA;AACH,GAAC,EAAE,CAACP,MAAM,CAAC,CAAC,CAAA;EAEZ,oBACE,KAAA,CAAA,aAAA,CAAC,kBAAkB,CAAC,QAAQ,EAAA;AAAC,IAAA,KAAK,EAAEA,MAAAA;AAAO,GAAA,EACxCI,QAAQ,CACmB,CAAA;AAElC;;;;"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var React = require('react');
|
|
6
4
|
|
|
7
|
-
function
|
|
8
|
-
if (e && e.__esModule) return e;
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
9
6
|
var n = Object.create(null);
|
|
10
7
|
if (e) {
|
|
11
8
|
Object.keys(e).forEach(function (k) {
|
|
@@ -18,53 +15,26 @@ function _interopNamespace(e) {
|
|
|
18
15
|
}
|
|
19
16
|
});
|
|
20
17
|
}
|
|
21
|
-
n
|
|
18
|
+
n.default = e;
|
|
22
19
|
return Object.freeze(n);
|
|
23
20
|
}
|
|
24
21
|
|
|
25
|
-
var React__namespace = /*#__PURE__*/
|
|
26
|
-
|
|
27
|
-
const defaultContext = /*#__PURE__*/React__namespace.createContext(undefined);
|
|
28
|
-
const QueryClientSharingContext = /*#__PURE__*/React__namespace.createContext(false); // If we are given a context, we will use it.
|
|
29
|
-
// Otherwise, if contextSharing is on, we share the first and at least one
|
|
30
|
-
// instance of the context across the window
|
|
31
|
-
// to ensure that if React Query is used across
|
|
32
|
-
// different bundles or microfrontends they will
|
|
33
|
-
// all use the same **instance** of context, regardless
|
|
34
|
-
// of module scoping.
|
|
22
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
35
23
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
const QueryClientContext = /*#__PURE__*/React__namespace.createContext(undefined);
|
|
25
|
+
const useQueryClient = queryClient => {
|
|
26
|
+
const client = React__namespace.useContext(QueryClientContext);
|
|
27
|
+
if (queryClient) {
|
|
28
|
+
return queryClient;
|
|
39
29
|
}
|
|
40
|
-
|
|
41
|
-
if (contextSharing && typeof window !== 'undefined') {
|
|
42
|
-
if (!window.ReactQueryClientContext) {
|
|
43
|
-
window.ReactQueryClientContext = defaultContext;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return window.ReactQueryClientContext;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return defaultContext;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const useQueryClient = ({
|
|
53
|
-
context
|
|
54
|
-
} = {}) => {
|
|
55
|
-
const queryClient = React__namespace.useContext(getQueryClientContext(context, React__namespace.useContext(QueryClientSharingContext)));
|
|
56
|
-
|
|
57
|
-
if (!queryClient) {
|
|
30
|
+
if (!client) {
|
|
58
31
|
throw new Error('No QueryClient set, use QueryClientProvider to set one');
|
|
59
32
|
}
|
|
60
|
-
|
|
61
|
-
return queryClient;
|
|
33
|
+
return client;
|
|
62
34
|
};
|
|
63
35
|
const QueryClientProvider = ({
|
|
64
36
|
client,
|
|
65
|
-
children
|
|
66
|
-
context,
|
|
67
|
-
contextSharing = false
|
|
37
|
+
children
|
|
68
38
|
}) => {
|
|
69
39
|
React__namespace.useEffect(() => {
|
|
70
40
|
client.mount();
|
|
@@ -72,20 +42,12 @@ const QueryClientProvider = ({
|
|
|
72
42
|
client.unmount();
|
|
73
43
|
};
|
|
74
44
|
}, [client]);
|
|
75
|
-
|
|
76
|
-
if (process.env.NODE_ENV !== 'production' && contextSharing) {
|
|
77
|
-
client.getLogger().error("The contextSharing option has been deprecated and will be removed in the next major version");
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const Context = getQueryClientContext(context, contextSharing);
|
|
81
|
-
return /*#__PURE__*/React__namespace.createElement(QueryClientSharingContext.Provider, {
|
|
82
|
-
value: !context && contextSharing
|
|
83
|
-
}, /*#__PURE__*/React__namespace.createElement(Context.Provider, {
|
|
45
|
+
return /*#__PURE__*/React__namespace.createElement(QueryClientContext.Provider, {
|
|
84
46
|
value: client
|
|
85
|
-
}, children)
|
|
47
|
+
}, children);
|
|
86
48
|
};
|
|
87
49
|
|
|
50
|
+
exports.QueryClientContext = QueryClientContext;
|
|
88
51
|
exports.QueryClientProvider = QueryClientProvider;
|
|
89
|
-
exports.defaultContext = defaultContext;
|
|
90
52
|
exports.useQueryClient = useQueryClient;
|
|
91
53
|
//# sourceMappingURL=QueryClientProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClientProvider.js","sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\
|
|
1
|
+
{"version":3,"file":"QueryClientProvider.js","sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\n\nexport const QueryClientContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\n\nexport const useQueryClient = (queryClient?: QueryClient) => {\n const client = React.useContext(QueryClientContext)\n\n if (queryClient) {\n return queryClient\n }\n\n if (!client) {\n throw new Error('No QueryClient set, use QueryClientProvider to set one')\n }\n\n return client\n}\n\nexport type QueryClientProviderProps = {\n client: QueryClient\n children?: React.ReactNode\n}\n\nexport const QueryClientProvider = ({\n client,\n children,\n}: QueryClientProviderProps): JSX.Element => {\n React.useEffect(() => {\n client.mount()\n return () => {\n client.unmount()\n }\n }, [client])\n\n return (\n <QueryClientContext.Provider value={client}>\n {children}\n </QueryClientContext.Provider>\n )\n}\n"],"names":["QueryClientContext","React","createContext","undefined","useQueryClient","queryClient","client","useContext","Error","QueryClientProvider","children","useEffect","mount","unmount"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAKO,MAAMA,kBAAkB,gBAAGC,gBAAK,CAACC,aAAa,CACnDC,SAAS,EACV;AAEYC,MAAAA,cAAc,GAAIC,WAAyB,IAAK;AAC3D,EAAA,MAAMC,MAAM,GAAGL,gBAAK,CAACM,UAAU,CAACP,kBAAkB,CAAC,CAAA;AAEnD,EAAA,IAAIK,WAAW,EAAE;AACf,IAAA,OAAOA,WAAW,CAAA;AACpB,GAAA;EAEA,IAAI,CAACC,MAAM,EAAE;AACX,IAAA,MAAM,IAAIE,KAAK,CAAC,wDAAwD,CAAC,CAAA;AAC3E,GAAA;AAEA,EAAA,OAAOF,MAAM,CAAA;AACf,EAAC;AAOM,MAAMG,mBAAmB,GAAG,CAAC;EAClCH,MAAM;AACNI,EAAAA,QAAAA;AACwB,CAAC,KAAkB;EAC3CT,gBAAK,CAACU,SAAS,CAAC,MAAM;IACpBL,MAAM,CAACM,KAAK,EAAE,CAAA;AACd,IAAA,OAAO,MAAM;MACXN,MAAM,CAACO,OAAO,EAAE,CAAA;KACjB,CAAA;AACH,GAAC,EAAE,CAACP,MAAM,CAAC,CAAC,CAAA;EAEZ,oBACEL,gBAAA,CAAA,aAAA,CAAC,kBAAkB,CAAC,QAAQ,EAAA;AAAC,IAAA,KAAK,EAAEK,MAAAA;AAAO,GAAA,EACxCI,QAAQ,CACmB,CAAA;AAElC;;;;;;"}
|
|
@@ -1,46 +1,19 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// different bundles or microfrontends they will
|
|
9
|
-
// all use the same **instance** of context, regardless
|
|
10
|
-
// of module scoping.
|
|
11
|
-
|
|
12
|
-
function getQueryClientContext(context, contextSharing) {
|
|
13
|
-
if (context) {
|
|
14
|
-
return context;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (contextSharing && typeof window !== 'undefined') {
|
|
18
|
-
if (!window.ReactQueryClientContext) {
|
|
19
|
-
window.ReactQueryClientContext = defaultContext;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return window.ReactQueryClientContext;
|
|
3
|
+
const QueryClientContext = /*#__PURE__*/React.createContext(undefined);
|
|
4
|
+
const useQueryClient = queryClient => {
|
|
5
|
+
const client = React.useContext(QueryClientContext);
|
|
6
|
+
if (queryClient) {
|
|
7
|
+
return queryClient;
|
|
23
8
|
}
|
|
24
|
-
|
|
25
|
-
return defaultContext;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const useQueryClient = ({
|
|
29
|
-
context
|
|
30
|
-
} = {}) => {
|
|
31
|
-
const queryClient = React.useContext(getQueryClientContext(context, React.useContext(QueryClientSharingContext)));
|
|
32
|
-
|
|
33
|
-
if (!queryClient) {
|
|
9
|
+
if (!client) {
|
|
34
10
|
throw new Error('No QueryClient set, use QueryClientProvider to set one');
|
|
35
11
|
}
|
|
36
|
-
|
|
37
|
-
return queryClient;
|
|
12
|
+
return client;
|
|
38
13
|
};
|
|
39
14
|
const QueryClientProvider = ({
|
|
40
15
|
client,
|
|
41
|
-
children
|
|
42
|
-
context,
|
|
43
|
-
contextSharing = false
|
|
16
|
+
children
|
|
44
17
|
}) => {
|
|
45
18
|
React.useEffect(() => {
|
|
46
19
|
client.mount();
|
|
@@ -48,18 +21,10 @@ const QueryClientProvider = ({
|
|
|
48
21
|
client.unmount();
|
|
49
22
|
};
|
|
50
23
|
}, [client]);
|
|
51
|
-
|
|
52
|
-
if (process.env.NODE_ENV !== 'production' && contextSharing) {
|
|
53
|
-
client.getLogger().error("The contextSharing option has been deprecated and will be removed in the next major version");
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const Context = getQueryClientContext(context, contextSharing);
|
|
57
|
-
return /*#__PURE__*/React.createElement(QueryClientSharingContext.Provider, {
|
|
58
|
-
value: !context && contextSharing
|
|
59
|
-
}, /*#__PURE__*/React.createElement(Context.Provider, {
|
|
24
|
+
return /*#__PURE__*/React.createElement(QueryClientContext.Provider, {
|
|
60
25
|
value: client
|
|
61
|
-
}, children)
|
|
26
|
+
}, children);
|
|
62
27
|
};
|
|
63
28
|
|
|
64
|
-
export {
|
|
29
|
+
export { QueryClientContext, QueryClientProvider, useQueryClient };
|
|
65
30
|
//# sourceMappingURL=QueryClientProvider.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClientProvider.mjs","sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\
|
|
1
|
+
{"version":3,"file":"QueryClientProvider.mjs","sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\n\nexport const QueryClientContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\n\nexport const useQueryClient = (queryClient?: QueryClient) => {\n const client = React.useContext(QueryClientContext)\n\n if (queryClient) {\n return queryClient\n }\n\n if (!client) {\n throw new Error('No QueryClient set, use QueryClientProvider to set one')\n }\n\n return client\n}\n\nexport type QueryClientProviderProps = {\n client: QueryClient\n children?: React.ReactNode\n}\n\nexport const QueryClientProvider = ({\n client,\n children,\n}: QueryClientProviderProps): JSX.Element => {\n React.useEffect(() => {\n client.mount()\n return () => {\n client.unmount()\n }\n }, [client])\n\n return (\n <QueryClientContext.Provider value={client}>\n {children}\n </QueryClientContext.Provider>\n )\n}\n"],"names":["QueryClientContext","React","createContext","undefined","useQueryClient","queryClient","client","useContext","Error","QueryClientProvider","children","useEffect","mount","unmount"],"mappings":";;AAKO,MAAMA,kBAAkB,gBAAGC,KAAK,CAACC,aAAa,CACnDC,SAAS,EACV;AAEYC,MAAAA,cAAc,GAAIC,WAAyB,IAAK;AAC3D,EAAA,MAAMC,MAAM,GAAGL,KAAK,CAACM,UAAU,CAACP,kBAAkB,CAAC,CAAA;AAEnD,EAAA,IAAIK,WAAW,EAAE;AACf,IAAA,OAAOA,WAAW,CAAA;AACpB,GAAA;EAEA,IAAI,CAACC,MAAM,EAAE;AACX,IAAA,MAAM,IAAIE,KAAK,CAAC,wDAAwD,CAAC,CAAA;AAC3E,GAAA;AAEA,EAAA,OAAOF,MAAM,CAAA;AACf,EAAC;AAOM,MAAMG,mBAAmB,GAAG,CAAC;EAClCH,MAAM;AACNI,EAAAA,QAAAA;AACwB,CAAC,KAAkB;EAC3CT,KAAK,CAACU,SAAS,CAAC,MAAM;IACpBL,MAAM,CAACM,KAAK,EAAE,CAAA;AACd,IAAA,OAAO,MAAM;MACXN,MAAM,CAACO,OAAO,EAAE,CAAA;KACjB,CAAA;AACH,GAAC,EAAE,CAACP,MAAM,CAAC,CAAC,CAAA;EAEZ,oBACE,KAAA,CAAA,aAAA,CAAC,kBAAkB,CAAC,QAAQ,EAAA;AAAC,IAAA,KAAK,EAAEA,MAAAA;AAAO,GAAA,EACxCI,QAAQ,CACmB,CAAA;AAElC;;;;"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
+
// CONTEXT
|
|
4
|
+
|
|
3
5
|
function createValue() {
|
|
4
6
|
let isReset = false;
|
|
5
7
|
return {
|
|
@@ -14,10 +16,13 @@ function createValue() {
|
|
|
14
16
|
}
|
|
15
17
|
};
|
|
16
18
|
}
|
|
19
|
+
const QueryErrorResetBoundaryContext = /*#__PURE__*/React.createContext(createValue());
|
|
20
|
+
|
|
21
|
+
// HOOK
|
|
17
22
|
|
|
18
|
-
const
|
|
23
|
+
const useQueryErrorResetBoundary = () => React.useContext(QueryErrorResetBoundaryContext);
|
|
19
24
|
|
|
20
|
-
|
|
25
|
+
// COMPONENT
|
|
21
26
|
|
|
22
27
|
const QueryErrorResetBoundary = ({
|
|
23
28
|
children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryErrorResetBoundary.esm.js","sources":["../../src/QueryErrorResetBoundary.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\n// CONTEXT\n\nexport interface QueryErrorResetBoundaryValue {\n clearReset: () => void\n isReset: () => boolean\n reset: () => void\n}\n\nfunction createValue(): QueryErrorResetBoundaryValue {\n let isReset = false\n return {\n clearReset: () => {\n isReset = false\n },\n reset: () => {\n isReset = true\n },\n isReset: () => {\n return isReset\n },\n }\n}\n\nconst QueryErrorResetBoundaryContext = React.createContext(createValue())\n\n// HOOK\n\nexport const useQueryErrorResetBoundary = () =>\n React.useContext(QueryErrorResetBoundaryContext)\n\n// COMPONENT\n\nexport interface QueryErrorResetBoundaryProps {\n children:\n | ((value: QueryErrorResetBoundaryValue) => React.ReactNode)\n | React.ReactNode\n}\n\nexport const QueryErrorResetBoundary = ({\n children,\n}: QueryErrorResetBoundaryProps) => {\n const [value] = React.useState(() => createValue())\n return (\n <QueryErrorResetBoundaryContext.Provider value={value}>\n {typeof children === 'function'\n ? (children as Function)(value)\n : children}\n </QueryErrorResetBoundaryContext.Provider>\n )\n}\n"],"names":["createValue","isReset","clearReset","reset","QueryErrorResetBoundaryContext","React","createContext","useQueryErrorResetBoundary","useContext","QueryErrorResetBoundary","children","value","useState"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"QueryErrorResetBoundary.esm.js","sources":["../../src/QueryErrorResetBoundary.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\n// CONTEXT\n\nexport interface QueryErrorResetBoundaryValue {\n clearReset: () => void\n isReset: () => boolean\n reset: () => void\n}\n\nfunction createValue(): QueryErrorResetBoundaryValue {\n let isReset = false\n return {\n clearReset: () => {\n isReset = false\n },\n reset: () => {\n isReset = true\n },\n isReset: () => {\n return isReset\n },\n }\n}\n\nconst QueryErrorResetBoundaryContext = React.createContext(createValue())\n\n// HOOK\n\nexport const useQueryErrorResetBoundary = () =>\n React.useContext(QueryErrorResetBoundaryContext)\n\n// COMPONENT\n\nexport interface QueryErrorResetBoundaryProps {\n children:\n | ((value: QueryErrorResetBoundaryValue) => React.ReactNode)\n | React.ReactNode\n}\n\nexport const QueryErrorResetBoundary = ({\n children,\n}: QueryErrorResetBoundaryProps) => {\n const [value] = React.useState(() => createValue())\n return (\n <QueryErrorResetBoundaryContext.Provider value={value}>\n {typeof children === 'function'\n ? (children as Function)(value)\n : children}\n </QueryErrorResetBoundaryContext.Provider>\n )\n}\n"],"names":["createValue","isReset","clearReset","reset","QueryErrorResetBoundaryContext","React","createContext","useQueryErrorResetBoundary","useContext","QueryErrorResetBoundary","children","value","useState"],"mappings":";;AAGA;;AAQA,SAASA,WAAW,GAAiC;EACnD,IAAIC,OAAO,GAAG,KAAK,CAAA;EACnB,OAAO;AACLC,IAAAA,UAAU,EAAE,MAAM;AAChBD,MAAAA,OAAO,GAAG,KAAK,CAAA;KAChB;AACDE,IAAAA,KAAK,EAAE,MAAM;AACXF,MAAAA,OAAO,GAAG,IAAI,CAAA;KACf;AACDA,IAAAA,OAAO,EAAE,MAAM;AACb,MAAA,OAAOA,OAAO,CAAA;AAChB,KAAA;GACD,CAAA;AACH,CAAA;AAEA,MAAMG,8BAA8B,gBAAGC,KAAK,CAACC,aAAa,CAACN,WAAW,EAAE,CAAC,CAAA;;AAEzE;;AAEO,MAAMO,0BAA0B,GAAG,MACxCF,KAAK,CAACG,UAAU,CAACJ,8BAA8B,EAAC;;AAElD;;AAQO,MAAMK,uBAAuB,GAAG,CAAC;AACtCC,EAAAA,QAAAA;AAC4B,CAAC,KAAK;EAClC,MAAM,CAACC,KAAK,CAAC,GAAGN,KAAK,CAACO,QAAQ,CAAC,MAAMZ,WAAW,EAAE,CAAC,CAAA;EACnD,oBACE,KAAA,CAAA,aAAA,CAAC,8BAA8B,CAAC,QAAQ,EAAA;AAAC,IAAA,KAAK,EAAEW,KAAAA;GAC7C,EAAA,OAAOD,QAAQ,KAAK,UAAU,GAC1BA,QAAQ,CAAcC,KAAK,CAAC,GAC7BD,QAAQ,CAC4B,CAAA;AAE9C;;;;"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var React = require('react');
|
|
6
4
|
|
|
7
|
-
function
|
|
8
|
-
if (e && e.__esModule) return e;
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
9
6
|
var n = Object.create(null);
|
|
10
7
|
if (e) {
|
|
11
8
|
Object.keys(e).forEach(function (k) {
|
|
@@ -18,11 +15,13 @@ function _interopNamespace(e) {
|
|
|
18
15
|
}
|
|
19
16
|
});
|
|
20
17
|
}
|
|
21
|
-
n
|
|
18
|
+
n.default = e;
|
|
22
19
|
return Object.freeze(n);
|
|
23
20
|
}
|
|
24
21
|
|
|
25
|
-
var React__namespace = /*#__PURE__*/
|
|
22
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
23
|
+
|
|
24
|
+
// CONTEXT
|
|
26
25
|
|
|
27
26
|
function createValue() {
|
|
28
27
|
let isReset = false;
|
|
@@ -38,10 +37,13 @@ function createValue() {
|
|
|
38
37
|
}
|
|
39
38
|
};
|
|
40
39
|
}
|
|
40
|
+
const QueryErrorResetBoundaryContext = /*#__PURE__*/React__namespace.createContext(createValue());
|
|
41
|
+
|
|
42
|
+
// HOOK
|
|
41
43
|
|
|
42
|
-
const
|
|
44
|
+
const useQueryErrorResetBoundary = () => React__namespace.useContext(QueryErrorResetBoundaryContext);
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
// COMPONENT
|
|
45
47
|
|
|
46
48
|
const QueryErrorResetBoundary = ({
|
|
47
49
|
children
|