@tanstack/preact-query 5.102.4 → 5.102.5
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/legacy/QueryErrorResetBoundary.cjs +11 -9
- package/build/legacy/QueryErrorResetBoundary.cjs.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.d.cts +11 -9
- package/build/legacy/QueryErrorResetBoundary.d.cts.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.d.ts +11 -9
- package/build/legacy/QueryErrorResetBoundary.d.ts.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.js +11 -9
- package/build/legacy/QueryErrorResetBoundary.js.map +1 -1
- package/build/legacy/useInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useInfiniteQuery.d.cts +28 -24
- package/build/legacy/useInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/useInfiniteQuery.d.ts +28 -24
- package/build/legacy/useInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/useInfiniteQuery.js.map +1 -1
- package/build/legacy/useIsFetching.cjs +14 -0
- package/build/legacy/useIsFetching.cjs.map +1 -1
- package/build/legacy/useIsFetching.d.cts +14 -0
- package/build/legacy/useIsFetching.d.cts.map +1 -1
- package/build/legacy/useIsFetching.d.ts +14 -0
- package/build/legacy/useIsFetching.d.ts.map +1 -1
- package/build/legacy/useIsFetching.js +14 -0
- package/build/legacy/useIsFetching.js.map +1 -1
- package/build/legacy/useMutation.cjs +104 -1
- package/build/legacy/useMutation.cjs.map +1 -1
- package/build/legacy/useMutation.d.cts +104 -1
- package/build/legacy/useMutation.d.cts.map +1 -1
- package/build/legacy/useMutation.d.ts +104 -1
- package/build/legacy/useMutation.d.ts.map +1 -1
- package/build/legacy/useMutation.js +104 -1
- package/build/legacy/useMutation.js.map +1 -1
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +54 -2
- package/build/legacy/useQuery.d.cts.map +1 -1
- package/build/legacy/useQuery.d.ts +54 -2
- package/build/legacy/useQuery.d.ts.map +1 -1
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.cjs +16 -8
- package/build/legacy/useSuspenseInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.cts +16 -8
- package/build/legacy/useSuspenseInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.ts +16 -8
- package/build/legacy/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.js +16 -8
- package/build/legacy/useSuspenseInfiniteQuery.js.map +1 -1
- package/build/legacy/useSuspenseQueries.cjs.map +1 -1
- package/build/legacy/useSuspenseQueries.d.cts +74 -6
- package/build/legacy/useSuspenseQueries.d.cts.map +1 -1
- package/build/legacy/useSuspenseQueries.d.ts +74 -6
- package/build/legacy/useSuspenseQueries.d.ts.map +1 -1
- package/build/legacy/useSuspenseQueries.js.map +1 -1
- package/build/legacy/useSuspenseQuery.cjs +4 -0
- package/build/legacy/useSuspenseQuery.cjs.map +1 -1
- package/build/legacy/useSuspenseQuery.d.cts +4 -0
- package/build/legacy/useSuspenseQuery.d.cts.map +1 -1
- package/build/legacy/useSuspenseQuery.d.ts +4 -0
- package/build/legacy/useSuspenseQuery.d.ts.map +1 -1
- package/build/legacy/useSuspenseQuery.js +4 -0
- package/build/legacy/useSuspenseQuery.js.map +1 -1
- package/build/modern/QueryErrorResetBoundary.cjs +11 -9
- package/build/modern/QueryErrorResetBoundary.cjs.map +1 -1
- package/build/modern/QueryErrorResetBoundary.d.cts +11 -9
- package/build/modern/QueryErrorResetBoundary.d.cts.map +1 -1
- package/build/modern/QueryErrorResetBoundary.d.ts +11 -9
- package/build/modern/QueryErrorResetBoundary.d.ts.map +1 -1
- package/build/modern/QueryErrorResetBoundary.js +11 -9
- package/build/modern/QueryErrorResetBoundary.js.map +1 -1
- package/build/modern/useInfiniteQuery.cjs.map +1 -1
- package/build/modern/useInfiniteQuery.d.cts +28 -24
- package/build/modern/useInfiniteQuery.d.cts.map +1 -1
- package/build/modern/useInfiniteQuery.d.ts +28 -24
- package/build/modern/useInfiniteQuery.d.ts.map +1 -1
- package/build/modern/useInfiniteQuery.js.map +1 -1
- package/build/modern/useIsFetching.cjs +14 -0
- package/build/modern/useIsFetching.cjs.map +1 -1
- package/build/modern/useIsFetching.d.cts +14 -0
- package/build/modern/useIsFetching.d.cts.map +1 -1
- package/build/modern/useIsFetching.d.ts +14 -0
- package/build/modern/useIsFetching.d.ts.map +1 -1
- package/build/modern/useIsFetching.js +14 -0
- package/build/modern/useIsFetching.js.map +1 -1
- package/build/modern/useMutation.cjs +104 -1
- package/build/modern/useMutation.cjs.map +1 -1
- package/build/modern/useMutation.d.cts +104 -1
- package/build/modern/useMutation.d.cts.map +1 -1
- package/build/modern/useMutation.d.ts +104 -1
- package/build/modern/useMutation.d.ts.map +1 -1
- package/build/modern/useMutation.js +104 -1
- package/build/modern/useMutation.js.map +1 -1
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +54 -2
- package/build/modern/useQuery.d.cts.map +1 -1
- package/build/modern/useQuery.d.ts +54 -2
- package/build/modern/useQuery.d.ts.map +1 -1
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.cjs +16 -8
- package/build/modern/useSuspenseInfiniteQuery.cjs.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.d.cts +16 -8
- package/build/modern/useSuspenseInfiniteQuery.d.cts.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.d.ts +16 -8
- package/build/modern/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.js +16 -8
- package/build/modern/useSuspenseInfiniteQuery.js.map +1 -1
- package/build/modern/useSuspenseQueries.cjs.map +1 -1
- package/build/modern/useSuspenseQueries.d.cts +74 -6
- package/build/modern/useSuspenseQueries.d.cts.map +1 -1
- package/build/modern/useSuspenseQueries.d.ts +74 -6
- package/build/modern/useSuspenseQueries.d.ts.map +1 -1
- package/build/modern/useSuspenseQueries.js.map +1 -1
- package/build/modern/useSuspenseQuery.cjs +4 -0
- package/build/modern/useSuspenseQuery.cjs.map +1 -1
- package/build/modern/useSuspenseQuery.d.cts +4 -0
- package/build/modern/useSuspenseQuery.d.cts.map +1 -1
- package/build/modern/useSuspenseQuery.d.ts +4 -0
- package/build/modern/useSuspenseQuery.d.ts.map +1 -1
- package/build/modern/useSuspenseQuery.js +4 -0
- package/build/modern/useSuspenseQuery.js.map +1 -1
- package/package.json +3 -3
- package/src/QueryErrorResetBoundary.tsx +11 -9
- package/src/useInfiniteQuery.ts +28 -24
- package/src/useIsFetching.ts +14 -0
- package/src/useMutation.ts +104 -1
- package/src/useQuery.ts +54 -2
- package/src/useSuspenseInfiniteQuery.ts +16 -8
- package/src/useSuspenseQueries.ts +74 -6
- package/src/useSuspenseQuery.ts +4 -0
|
@@ -83,15 +83,17 @@ const useQueryErrorResetBoundary = () => (0, preact_hooks.useContext)(QueryError
|
|
|
83
83
|
* return children
|
|
84
84
|
* }
|
|
85
85
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* <
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
86
|
+
* function App() {
|
|
87
|
+
* return (
|
|
88
|
+
* <QueryErrorResetBoundary>
|
|
89
|
+
* {({ reset }) => (
|
|
90
|
+
* <ErrorBoundary reset={reset}>
|
|
91
|
+
* <Page />
|
|
92
|
+
* </ErrorBoundary>
|
|
93
|
+
* )}
|
|
94
|
+
* </QueryErrorResetBoundary>
|
|
95
|
+
* )
|
|
96
|
+
* }
|
|
95
97
|
* ```
|
|
96
98
|
*/
|
|
97
99
|
const QueryErrorResetBoundary = ({ children }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryErrorResetBoundary.cjs","names":["createContext","useContext","useState"],"sources":["../../src/QueryErrorResetBoundary.tsx"],"sourcesContent":["import { createContext } from 'preact'\nimport type { ComponentChildren } from 'preact'\nimport { useContext, useState } from 'preact/hooks'\n\n// CONTEXT\n\n/**\n * Resets any query errors within the boundary, so queries know they can try again.\n */\nexport type QueryErrorResetFunction = () => void\n\n/**\n * Returns whether the boundary has been reset and not yet cleared.\n */\nexport type QueryErrorIsResetFunction = () => boolean\n\n/**\n * Clears the reset state, so queries know not to try again until the boundary is reset again.\n */\nexport type QueryErrorClearResetFunction = () => void\n\nexport interface QueryErrorResetBoundaryValue {\n /**\n * Clears the reset state, so queries know not to try again until the boundary is reset again.\n */\n clearReset: QueryErrorClearResetFunction\n /**\n * Returns whether the boundary has been reset and not yet cleared.\n */\n isReset: QueryErrorIsResetFunction\n /**\n * Resets any query errors within the boundary, so queries know they can try again.\n */\n reset: QueryErrorResetFunction\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 = createContext(createValue())\n\n// HOOK\n\n/**\n * This hook will reset any query errors within the closest `QueryErrorResetBoundary`. If there is no boundary\n * defined it will reset them globally.\n *\n * @returns The boundary's {@link QueryErrorResetBoundaryValue}.\n *\n * @example\n * ```tsx\n * import { useErrorBoundary } from 'preact/hooks'\n * import type { ComponentChildren } from 'preact'\n * import { useQueryErrorResetBoundary } from '@tanstack/preact-query'\n *\n * function App({ children }: { children: ComponentChildren }) {\n * const { reset } = useQueryErrorResetBoundary()\n * const [error, resetError] = useErrorBoundary(() => reset())\n *\n * if (error) {\n * return (\n * <div>\n * There was an error!\n * <button onClick={() => resetError()}>Try again</button>\n * </div>\n * )\n * }\n *\n * return children\n * }\n * ```\n */\nexport const useQueryErrorResetBoundary = () =>\n useContext(QueryErrorResetBoundaryContext)\n\n// COMPONENT\n\n/**\n * A render-prop function usable as `children` on `QueryErrorResetBoundary`.\n *\n * @param value - The boundary's {@link QueryErrorResetBoundaryValue}.\n * @returns The children to render.\n */\nexport type QueryErrorResetBoundaryFunction = (\n value: QueryErrorResetBoundaryValue,\n) => ComponentChildren\n\n/**\n * The props accepted by `QueryErrorResetBoundary`.\n */\nexport interface QueryErrorResetBoundaryProps {\n /**\n * Either a plain node, or a function that receives the boundary's {@link QueryErrorResetBoundaryValue} and\n * returns a node.\n */\n children: QueryErrorResetBoundaryFunction | ComponentChildren\n}\n\n/**\n * When using `suspense` or `throwOnError` in your queries, you need a way to let queries know that you want to\n * try again when re-rendering after some error occurred. With the `QueryErrorResetBoundary` component you can\n * reset any query errors within the boundaries of the component.\n *\n * @returns The `children`, rendered as-is, or called with the boundary's {@link QueryErrorResetBoundaryValue}\n * if `children` is a function.\n *\n * @example\n * ```tsx\n * import { useErrorBoundary } from 'preact/hooks'\n * import type { ComponentChildren } from 'preact'\n * import { QueryErrorResetBoundary } from '@tanstack/preact-query'\n *\n * function ErrorBoundary({\n * children,\n * reset,\n * }: {\n * children: ComponentChildren\n * reset: () => void\n * }) {\n * const [error, resetError] = useErrorBoundary(() => reset())\n *\n * if (error) {\n * return (\n * <div>\n * There was an error!\n * <button onClick={() => resetError()}>Try again</button>\n * </div>\n * )\n * }\n *\n * return children\n * }\n *\n *
|
|
1
|
+
{"version":3,"file":"QueryErrorResetBoundary.cjs","names":["createContext","useContext","useState"],"sources":["../../src/QueryErrorResetBoundary.tsx"],"sourcesContent":["import { createContext } from 'preact'\nimport type { ComponentChildren } from 'preact'\nimport { useContext, useState } from 'preact/hooks'\n\n// CONTEXT\n\n/**\n * Resets any query errors within the boundary, so queries know they can try again.\n */\nexport type QueryErrorResetFunction = () => void\n\n/**\n * Returns whether the boundary has been reset and not yet cleared.\n */\nexport type QueryErrorIsResetFunction = () => boolean\n\n/**\n * Clears the reset state, so queries know not to try again until the boundary is reset again.\n */\nexport type QueryErrorClearResetFunction = () => void\n\nexport interface QueryErrorResetBoundaryValue {\n /**\n * Clears the reset state, so queries know not to try again until the boundary is reset again.\n */\n clearReset: QueryErrorClearResetFunction\n /**\n * Returns whether the boundary has been reset and not yet cleared.\n */\n isReset: QueryErrorIsResetFunction\n /**\n * Resets any query errors within the boundary, so queries know they can try again.\n */\n reset: QueryErrorResetFunction\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 = createContext(createValue())\n\n// HOOK\n\n/**\n * This hook will reset any query errors within the closest `QueryErrorResetBoundary`. If there is no boundary\n * defined it will reset them globally.\n *\n * @returns The boundary's {@link QueryErrorResetBoundaryValue}.\n *\n * @example\n * ```tsx\n * import { useErrorBoundary } from 'preact/hooks'\n * import type { ComponentChildren } from 'preact'\n * import { useQueryErrorResetBoundary } from '@tanstack/preact-query'\n *\n * function App({ children }: { children: ComponentChildren }) {\n * const { reset } = useQueryErrorResetBoundary()\n * const [error, resetError] = useErrorBoundary(() => reset())\n *\n * if (error) {\n * return (\n * <div>\n * There was an error!\n * <button onClick={() => resetError()}>Try again</button>\n * </div>\n * )\n * }\n *\n * return children\n * }\n * ```\n */\nexport const useQueryErrorResetBoundary = () =>\n useContext(QueryErrorResetBoundaryContext)\n\n// COMPONENT\n\n/**\n * A render-prop function usable as `children` on `QueryErrorResetBoundary`.\n *\n * @param value - The boundary's {@link QueryErrorResetBoundaryValue}.\n * @returns The children to render.\n */\nexport type QueryErrorResetBoundaryFunction = (\n value: QueryErrorResetBoundaryValue,\n) => ComponentChildren\n\n/**\n * The props accepted by `QueryErrorResetBoundary`.\n */\nexport interface QueryErrorResetBoundaryProps {\n /**\n * Either a plain node, or a function that receives the boundary's {@link QueryErrorResetBoundaryValue} and\n * returns a node.\n */\n children: QueryErrorResetBoundaryFunction | ComponentChildren\n}\n\n/**\n * When using `suspense` or `throwOnError` in your queries, you need a way to let queries know that you want to\n * try again when re-rendering after some error occurred. With the `QueryErrorResetBoundary` component you can\n * reset any query errors within the boundaries of the component.\n *\n * @returns The `children`, rendered as-is, or called with the boundary's {@link QueryErrorResetBoundaryValue}\n * if `children` is a function.\n *\n * @example\n * ```tsx\n * import { useErrorBoundary } from 'preact/hooks'\n * import type { ComponentChildren } from 'preact'\n * import { QueryErrorResetBoundary } from '@tanstack/preact-query'\n *\n * function ErrorBoundary({\n * children,\n * reset,\n * }: {\n * children: ComponentChildren\n * reset: () => void\n * }) {\n * const [error, resetError] = useErrorBoundary(() => reset())\n *\n * if (error) {\n * return (\n * <div>\n * There was an error!\n * <button onClick={() => resetError()}>Try again</button>\n * </div>\n * )\n * }\n *\n * return children\n * }\n *\n * function App() {\n * return (\n * <QueryErrorResetBoundary>\n * {({ reset }) => (\n * <ErrorBoundary reset={reset}>\n * <Page />\n * </ErrorBoundary>\n * )}\n * </QueryErrorResetBoundary>\n * )\n * }\n * ```\n */\nexport const QueryErrorResetBoundary = ({\n children,\n}: QueryErrorResetBoundaryProps) => {\n const [value] = useState(() => createValue())\n return (\n <QueryErrorResetBoundaryContext.Provider value={value}>\n {typeof children === 'function' ? children(value) : children}\n </QueryErrorResetBoundaryContext.Provider>\n )\n}\n"],"mappings":";;;;;AAoCA,SAAS,cAA4C;CACnD,IAAI,UAAU;CACd,OAAO;EACL,kBAAkB;GAChB,UAAU;EACZ;EACA,aAAa;GACX,UAAU;EACZ;EACA,eAAe;GACb,OAAO;EACT;CACF;AACF;AAEA,MAAM,kCAAA,GAAiCA,OAAAA,cAAAA,CAAc,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiClE,MAAa,oCAAA,GACXC,aAAAA,WAAAA,CAAW,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyE3C,MAAa,2BAA2B,EACtC,eACkC;CAClC,MAAM,CAAC,UAAA,GAASC,aAAAA,SAAAA,OAAe,YAAY,CAAC;CAC5C,OACE,iBAAA,GAAA,mBAAA,IAAA,CAAC,+BAA+B,UAAhC;EAAgD;EAC7C,UAAA,OAAO,aAAa,aAAa,SAAS,KAAK,IAAI;CACb,CAAA;AAE7C"}
|
|
@@ -108,15 +108,17 @@ interface QueryErrorResetBoundaryProps {
|
|
|
108
108
|
* return children
|
|
109
109
|
* }
|
|
110
110
|
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* <
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
111
|
+
* function App() {
|
|
112
|
+
* return (
|
|
113
|
+
* <QueryErrorResetBoundary>
|
|
114
|
+
* {({ reset }) => (
|
|
115
|
+
* <ErrorBoundary reset={reset}>
|
|
116
|
+
* <Page />
|
|
117
|
+
* </ErrorBoundary>
|
|
118
|
+
* )}
|
|
119
|
+
* </QueryErrorResetBoundary>
|
|
120
|
+
* )
|
|
121
|
+
* }
|
|
120
122
|
* ```
|
|
121
123
|
*/
|
|
122
124
|
declare const QueryErrorResetBoundary: ({ children }: QueryErrorResetBoundaryProps) => import("preact").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryErrorResetBoundary.d.cts","names":[],"sources":["../../src/QueryErrorResetBoundary.tsx"],"mappings":";;;;;KASY;;;;KAKA;;;;KAKA;UAEK;;;;EAIf,YAAY;;;;EAIZ,SAAS;;;;EAIT,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmDI,kCAA0B;;;;;;;KAW3B,mCACV,OAAO,iCACJ;;;;UAKY;;;;;EAKf,UAAU,kCAAkC
|
|
1
|
+
{"version":3,"file":"QueryErrorResetBoundary.d.cts","names":[],"sources":["../../src/QueryErrorResetBoundary.tsx"],"mappings":";;;;;KASY;;;;KAKA;;;;KAKA;UAEK;;;;EAIf,YAAY;;;;EAIZ,SAAS;;;;EAIT,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmDI,kCAA0B;;;;;;;KAW3B,mCACV,OAAO,iCACJ;;;;UAKY;;;;;EAKf,UAAU,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmDjC,4BAA2B,YAErC,kDAA4B,IAAA"}
|
|
@@ -108,15 +108,17 @@ interface QueryErrorResetBoundaryProps {
|
|
|
108
108
|
* return children
|
|
109
109
|
* }
|
|
110
110
|
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* <
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
111
|
+
* function App() {
|
|
112
|
+
* return (
|
|
113
|
+
* <QueryErrorResetBoundary>
|
|
114
|
+
* {({ reset }) => (
|
|
115
|
+
* <ErrorBoundary reset={reset}>
|
|
116
|
+
* <Page />
|
|
117
|
+
* </ErrorBoundary>
|
|
118
|
+
* )}
|
|
119
|
+
* </QueryErrorResetBoundary>
|
|
120
|
+
* )
|
|
121
|
+
* }
|
|
120
122
|
* ```
|
|
121
123
|
*/
|
|
122
124
|
declare const QueryErrorResetBoundary: ({ children }: QueryErrorResetBoundaryProps) => import("preact").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryErrorResetBoundary.d.ts","names":[],"sources":["../../src/QueryErrorResetBoundary.tsx"],"mappings":";;;;;KASY;;;;KAKA;;;;KAKA;UAEK;;;;EAIf,YAAY;;;;EAIZ,SAAS;;;;EAIT,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmDI,kCAA0B;;;;;;;KAW3B,mCACV,OAAO,iCACJ;;;;UAKY;;;;;EAKf,UAAU,kCAAkC
|
|
1
|
+
{"version":3,"file":"QueryErrorResetBoundary.d.ts","names":[],"sources":["../../src/QueryErrorResetBoundary.tsx"],"mappings":";;;;;KASY;;;;KAKA;;;;KAKA;UAEK;;;;EAIf,YAAY;;;;EAIZ,SAAS;;;;EAIT,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmDI,kCAA0B;;;;;;;KAW3B,mCACV,OAAO,iCACJ;;;;UAKY;;;;;EAKf,UAAU,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmDjC,4BAA2B,YAErC,kDAA4B,IAAA"}
|
|
@@ -82,15 +82,17 @@ const useQueryErrorResetBoundary = () => useContext(QueryErrorResetBoundaryConte
|
|
|
82
82
|
* return children
|
|
83
83
|
* }
|
|
84
84
|
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* <
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
85
|
+
* function App() {
|
|
86
|
+
* return (
|
|
87
|
+
* <QueryErrorResetBoundary>
|
|
88
|
+
* {({ reset }) => (
|
|
89
|
+
* <ErrorBoundary reset={reset}>
|
|
90
|
+
* <Page />
|
|
91
|
+
* </ErrorBoundary>
|
|
92
|
+
* )}
|
|
93
|
+
* </QueryErrorResetBoundary>
|
|
94
|
+
* )
|
|
95
|
+
* }
|
|
94
96
|
* ```
|
|
95
97
|
*/
|
|
96
98
|
const QueryErrorResetBoundary = ({ children }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryErrorResetBoundary.js","names":[],"sources":["../../src/QueryErrorResetBoundary.tsx"],"sourcesContent":["import { createContext } from 'preact'\nimport type { ComponentChildren } from 'preact'\nimport { useContext, useState } from 'preact/hooks'\n\n// CONTEXT\n\n/**\n * Resets any query errors within the boundary, so queries know they can try again.\n */\nexport type QueryErrorResetFunction = () => void\n\n/**\n * Returns whether the boundary has been reset and not yet cleared.\n */\nexport type QueryErrorIsResetFunction = () => boolean\n\n/**\n * Clears the reset state, so queries know not to try again until the boundary is reset again.\n */\nexport type QueryErrorClearResetFunction = () => void\n\nexport interface QueryErrorResetBoundaryValue {\n /**\n * Clears the reset state, so queries know not to try again until the boundary is reset again.\n */\n clearReset: QueryErrorClearResetFunction\n /**\n * Returns whether the boundary has been reset and not yet cleared.\n */\n isReset: QueryErrorIsResetFunction\n /**\n * Resets any query errors within the boundary, so queries know they can try again.\n */\n reset: QueryErrorResetFunction\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 = createContext(createValue())\n\n// HOOK\n\n/**\n * This hook will reset any query errors within the closest `QueryErrorResetBoundary`. If there is no boundary\n * defined it will reset them globally.\n *\n * @returns The boundary's {@link QueryErrorResetBoundaryValue}.\n *\n * @example\n * ```tsx\n * import { useErrorBoundary } from 'preact/hooks'\n * import type { ComponentChildren } from 'preact'\n * import { useQueryErrorResetBoundary } from '@tanstack/preact-query'\n *\n * function App({ children }: { children: ComponentChildren }) {\n * const { reset } = useQueryErrorResetBoundary()\n * const [error, resetError] = useErrorBoundary(() => reset())\n *\n * if (error) {\n * return (\n * <div>\n * There was an error!\n * <button onClick={() => resetError()}>Try again</button>\n * </div>\n * )\n * }\n *\n * return children\n * }\n * ```\n */\nexport const useQueryErrorResetBoundary = () =>\n useContext(QueryErrorResetBoundaryContext)\n\n// COMPONENT\n\n/**\n * A render-prop function usable as `children` on `QueryErrorResetBoundary`.\n *\n * @param value - The boundary's {@link QueryErrorResetBoundaryValue}.\n * @returns The children to render.\n */\nexport type QueryErrorResetBoundaryFunction = (\n value: QueryErrorResetBoundaryValue,\n) => ComponentChildren\n\n/**\n * The props accepted by `QueryErrorResetBoundary`.\n */\nexport interface QueryErrorResetBoundaryProps {\n /**\n * Either a plain node, or a function that receives the boundary's {@link QueryErrorResetBoundaryValue} and\n * returns a node.\n */\n children: QueryErrorResetBoundaryFunction | ComponentChildren\n}\n\n/**\n * When using `suspense` or `throwOnError` in your queries, you need a way to let queries know that you want to\n * try again when re-rendering after some error occurred. With the `QueryErrorResetBoundary` component you can\n * reset any query errors within the boundaries of the component.\n *\n * @returns The `children`, rendered as-is, or called with the boundary's {@link QueryErrorResetBoundaryValue}\n * if `children` is a function.\n *\n * @example\n * ```tsx\n * import { useErrorBoundary } from 'preact/hooks'\n * import type { ComponentChildren } from 'preact'\n * import { QueryErrorResetBoundary } from '@tanstack/preact-query'\n *\n * function ErrorBoundary({\n * children,\n * reset,\n * }: {\n * children: ComponentChildren\n * reset: () => void\n * }) {\n * const [error, resetError] = useErrorBoundary(() => reset())\n *\n * if (error) {\n * return (\n * <div>\n * There was an error!\n * <button onClick={() => resetError()}>Try again</button>\n * </div>\n * )\n * }\n *\n * return children\n * }\n *\n *
|
|
1
|
+
{"version":3,"file":"QueryErrorResetBoundary.js","names":[],"sources":["../../src/QueryErrorResetBoundary.tsx"],"sourcesContent":["import { createContext } from 'preact'\nimport type { ComponentChildren } from 'preact'\nimport { useContext, useState } from 'preact/hooks'\n\n// CONTEXT\n\n/**\n * Resets any query errors within the boundary, so queries know they can try again.\n */\nexport type QueryErrorResetFunction = () => void\n\n/**\n * Returns whether the boundary has been reset and not yet cleared.\n */\nexport type QueryErrorIsResetFunction = () => boolean\n\n/**\n * Clears the reset state, so queries know not to try again until the boundary is reset again.\n */\nexport type QueryErrorClearResetFunction = () => void\n\nexport interface QueryErrorResetBoundaryValue {\n /**\n * Clears the reset state, so queries know not to try again until the boundary is reset again.\n */\n clearReset: QueryErrorClearResetFunction\n /**\n * Returns whether the boundary has been reset and not yet cleared.\n */\n isReset: QueryErrorIsResetFunction\n /**\n * Resets any query errors within the boundary, so queries know they can try again.\n */\n reset: QueryErrorResetFunction\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 = createContext(createValue())\n\n// HOOK\n\n/**\n * This hook will reset any query errors within the closest `QueryErrorResetBoundary`. If there is no boundary\n * defined it will reset them globally.\n *\n * @returns The boundary's {@link QueryErrorResetBoundaryValue}.\n *\n * @example\n * ```tsx\n * import { useErrorBoundary } from 'preact/hooks'\n * import type { ComponentChildren } from 'preact'\n * import { useQueryErrorResetBoundary } from '@tanstack/preact-query'\n *\n * function App({ children }: { children: ComponentChildren }) {\n * const { reset } = useQueryErrorResetBoundary()\n * const [error, resetError] = useErrorBoundary(() => reset())\n *\n * if (error) {\n * return (\n * <div>\n * There was an error!\n * <button onClick={() => resetError()}>Try again</button>\n * </div>\n * )\n * }\n *\n * return children\n * }\n * ```\n */\nexport const useQueryErrorResetBoundary = () =>\n useContext(QueryErrorResetBoundaryContext)\n\n// COMPONENT\n\n/**\n * A render-prop function usable as `children` on `QueryErrorResetBoundary`.\n *\n * @param value - The boundary's {@link QueryErrorResetBoundaryValue}.\n * @returns The children to render.\n */\nexport type QueryErrorResetBoundaryFunction = (\n value: QueryErrorResetBoundaryValue,\n) => ComponentChildren\n\n/**\n * The props accepted by `QueryErrorResetBoundary`.\n */\nexport interface QueryErrorResetBoundaryProps {\n /**\n * Either a plain node, or a function that receives the boundary's {@link QueryErrorResetBoundaryValue} and\n * returns a node.\n */\n children: QueryErrorResetBoundaryFunction | ComponentChildren\n}\n\n/**\n * When using `suspense` or `throwOnError` in your queries, you need a way to let queries know that you want to\n * try again when re-rendering after some error occurred. With the `QueryErrorResetBoundary` component you can\n * reset any query errors within the boundaries of the component.\n *\n * @returns The `children`, rendered as-is, or called with the boundary's {@link QueryErrorResetBoundaryValue}\n * if `children` is a function.\n *\n * @example\n * ```tsx\n * import { useErrorBoundary } from 'preact/hooks'\n * import type { ComponentChildren } from 'preact'\n * import { QueryErrorResetBoundary } from '@tanstack/preact-query'\n *\n * function ErrorBoundary({\n * children,\n * reset,\n * }: {\n * children: ComponentChildren\n * reset: () => void\n * }) {\n * const [error, resetError] = useErrorBoundary(() => reset())\n *\n * if (error) {\n * return (\n * <div>\n * There was an error!\n * <button onClick={() => resetError()}>Try again</button>\n * </div>\n * )\n * }\n *\n * return children\n * }\n *\n * function App() {\n * return (\n * <QueryErrorResetBoundary>\n * {({ reset }) => (\n * <ErrorBoundary reset={reset}>\n * <Page />\n * </ErrorBoundary>\n * )}\n * </QueryErrorResetBoundary>\n * )\n * }\n * ```\n */\nexport const QueryErrorResetBoundary = ({\n children,\n}: QueryErrorResetBoundaryProps) => {\n const [value] = useState(() => createValue())\n return (\n <QueryErrorResetBoundaryContext.Provider value={value}>\n {typeof children === 'function' ? children(value) : children}\n </QueryErrorResetBoundaryContext.Provider>\n )\n}\n"],"mappings":";;;;AAoCA,SAAS,cAA4C;CACnD,IAAI,UAAU;CACd,OAAO;EACL,kBAAkB;GAChB,UAAU;EACZ;EACA,aAAa;GACX,UAAU;EACZ;EACA,eAAe;GACb,OAAO;EACT;CACF;AACF;AAEA,MAAM,iCAAiC,cAAc,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiClE,MAAa,mCACX,WAAW,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyE3C,MAAa,2BAA2B,EACtC,eACkC;CAClC,MAAM,CAAC,SAAS,eAAe,YAAY,CAAC;CAC5C,OACE,oBAAC,+BAA+B,UAAhC;EAAgD;EAC7C,UAAA,OAAO,aAAa,aAAa,SAAS,KAAK,IAAI;CACb,CAAA;AAE7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInfiniteQuery.cjs","names":["useBaseQuery","InfiniteQueryObserver"],"sources":["../../src/useInfiniteQuery.ts"],"sourcesContent":["import { InfiniteQueryObserver } from '@tanstack/query-core'\nimport type {\n DefaultError,\n InfiniteData,\n QueryClient,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\n\nimport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infiniteQueryOptions'\nimport type {\n DefinedUseInfiniteQueryResult,\n UseInfiniteQueryOptions,\n UseInfiniteQueryResult,\n} from './types'\nimport { useBaseQuery } from './useBaseQuery'\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `queryFn`,\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * This overload is selected when `initialData` is set.\n *\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` set.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The same properties as `useQuery`, with the addition of `data.pages`, `data.pageParams`,\n * `fetchNextPage`, `fetchPreviousPage`, `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and\n * `isFetchingPreviousPage`.\n *\n * @example\n * ```tsx\n * import { useInfiniteQuery } from '@tanstack/preact-query'\n *\n * function Projects() {\n * const { data } = useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n *\n * return <>{data.pages.map((page) => page.projects.map((p) => <p key={p.id}>{p.name}</p>))}</>\n * }\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: QueryClient,\n): DefinedUseInfiniteQueryResult<TData, TError>\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `queryFn`,\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The same properties as `useQuery`, with the addition of `data.pages`, `data.pageParams`,\n * `fetchNextPage`, `fetchPreviousPage`, `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and\n * `isFetchingPreviousPage`.\n *\n * @example\n * ```tsx\n * import {
|
|
1
|
+
{"version":3,"file":"useInfiniteQuery.cjs","names":["useBaseQuery","InfiniteQueryObserver"],"sources":["../../src/useInfiniteQuery.ts"],"sourcesContent":["import { InfiniteQueryObserver } from '@tanstack/query-core'\nimport type {\n DefaultError,\n InfiniteData,\n QueryClient,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\n\nimport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infiniteQueryOptions'\nimport type {\n DefinedUseInfiniteQueryResult,\n UseInfiniteQueryOptions,\n UseInfiniteQueryResult,\n} from './types'\nimport { useBaseQuery } from './useBaseQuery'\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `queryFn`,\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * This overload is selected when `initialData` is set.\n *\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` set.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The same properties as `useQuery`, with the addition of `data.pages`, `data.pageParams`,\n * `fetchNextPage`, `fetchPreviousPage`, `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and\n * `isFetchingPreviousPage`.\n *\n * @example\n * ```tsx\n * import { useInfiniteQuery } from '@tanstack/preact-query'\n *\n * function Projects() {\n * const { data } = useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n *\n * return <>{data.pages.map((page) => page.projects.map((p) => <p key={p.id}>{p.name}</p>))}</>\n * }\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: QueryClient,\n): DefinedUseInfiniteQueryResult<TData, TError>\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `queryFn`,\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The same properties as `useQuery`, with the addition of `data.pages`, `data.pageParams`,\n * `fetchNextPage`, `fetchPreviousPage`, `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and\n * `isFetchingPreviousPage`.\n *\n * @example\n * ```tsx\n * import { useInfiniteQuery } from '@tanstack/preact-query'\n *\n * function Projects() {\n * const { data, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage } =\n * useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * return (\n * <button\n * onClick={() => fetchNextPage()}\n * disabled={!hasNextPage || isFetching}\n * >\n * {isFetchingNextPage\n * ? 'Loading more...'\n * : hasNextPage\n * ? 'Load More'\n * : 'Nothing more to load'}\n * </button>\n * )\n * }\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: QueryClient,\n): UseInfiniteQueryResult<TData, TError>\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `queryFn`,\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`.\n * @param options - The {@link UseInfiniteQueryOptions} to use — everything you can pass to `useInfiniteQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The same properties as `useQuery`, with the addition of `data.pages`, `data.pageParams`,\n * `fetchNextPage`, `fetchPreviousPage`, `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and\n * `isFetchingPreviousPage`.\n *\n * @example\n * ```tsx\n * import { useInfiniteQuery } from '@tanstack/preact-query'\n *\n * function Projects() {\n * const { data, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage } =\n * useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * return (\n * <button\n * onClick={() => fetchNextPage()}\n * disabled={!hasNextPage || isFetching}\n * >\n * {isFetchingNextPage\n * ? 'Loading more...'\n * : hasNextPage\n * ? 'Load More'\n * : 'Nothing more to load'}\n * </button>\n * )\n * }\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: QueryClient,\n): UseInfiniteQueryResult<TData, TError>\n\nexport function useInfiniteQuery(\n options: UseInfiniteQueryOptions,\n queryClient?: QueryClient,\n) {\n return useBaseQuery(\n options,\n InfiniteQueryObserver as typeof QueryObserver,\n queryClient,\n )\n}\n"],"mappings":";;;;AA+LA,SAAgB,iBACd,SACA,aACA;CACA,OAAOA,qBAAAA,aACL,SACAC,qBAAAA,uBACA,WACF;AACF"}
|
|
@@ -54,25 +54,27 @@ declare function useInfiniteQuery<TQueryFnData, TError = DefaultError, TData = I
|
|
|
54
54
|
*
|
|
55
55
|
* @example
|
|
56
56
|
* ```tsx
|
|
57
|
-
* import {
|
|
58
|
-
*
|
|
59
|
-
* const projectsOptions = infiniteQueryOptions({
|
|
60
|
-
* queryKey: ['projects'],
|
|
61
|
-
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
62
|
-
* initialPageParam: 0,
|
|
63
|
-
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
64
|
-
* })
|
|
57
|
+
* import { useInfiniteQuery } from '@tanstack/preact-query'
|
|
65
58
|
*
|
|
66
59
|
* function Projects() {
|
|
67
|
-
* const { data, fetchNextPage, hasNextPage, isFetchingNextPage } =
|
|
68
|
-
* useInfiniteQuery(
|
|
60
|
+
* const { data, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage } =
|
|
61
|
+
* useInfiniteQuery({
|
|
62
|
+
* queryKey: ['projects'],
|
|
63
|
+
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
64
|
+
* initialPageParam: 0,
|
|
65
|
+
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
66
|
+
* })
|
|
69
67
|
*
|
|
70
68
|
* return (
|
|
71
69
|
* <button
|
|
72
70
|
* onClick={() => fetchNextPage()}
|
|
73
|
-
* disabled={!hasNextPage ||
|
|
71
|
+
* disabled={!hasNextPage || isFetching}
|
|
74
72
|
* >
|
|
75
|
-
*
|
|
73
|
+
* {isFetchingNextPage
|
|
74
|
+
* ? 'Loading more...'
|
|
75
|
+
* : hasNextPage
|
|
76
|
+
* ? 'Load More'
|
|
77
|
+
* : 'Nothing more to load'}
|
|
76
78
|
* </button>
|
|
77
79
|
* )
|
|
78
80
|
* }
|
|
@@ -96,25 +98,27 @@ declare function useInfiniteQuery<TQueryFnData, TError = DefaultError, TData = I
|
|
|
96
98
|
*
|
|
97
99
|
* @example
|
|
98
100
|
* ```tsx
|
|
99
|
-
* import {
|
|
100
|
-
*
|
|
101
|
-
* const projectsOptions = infiniteQueryOptions({
|
|
102
|
-
* queryKey: ['projects'],
|
|
103
|
-
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
104
|
-
* initialPageParam: 0,
|
|
105
|
-
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
106
|
-
* })
|
|
101
|
+
* import { useInfiniteQuery } from '@tanstack/preact-query'
|
|
107
102
|
*
|
|
108
103
|
* function Projects() {
|
|
109
|
-
* const { data, fetchNextPage, hasNextPage, isFetchingNextPage } =
|
|
110
|
-
* useInfiniteQuery(
|
|
104
|
+
* const { data, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage } =
|
|
105
|
+
* useInfiniteQuery({
|
|
106
|
+
* queryKey: ['projects'],
|
|
107
|
+
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
108
|
+
* initialPageParam: 0,
|
|
109
|
+
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
110
|
+
* })
|
|
111
111
|
*
|
|
112
112
|
* return (
|
|
113
113
|
* <button
|
|
114
114
|
* onClick={() => fetchNextPage()}
|
|
115
|
-
* disabled={!hasNextPage ||
|
|
115
|
+
* disabled={!hasNextPage || isFetching}
|
|
116
116
|
* >
|
|
117
|
-
*
|
|
117
|
+
* {isFetchingNextPage
|
|
118
|
+
* ? 'Loading more...'
|
|
119
|
+
* : hasNextPage
|
|
120
|
+
* ? 'Load More'
|
|
121
|
+
* : 'Nothing more to load'}
|
|
118
122
|
* </button>
|
|
119
123
|
* )
|
|
120
124
|
* }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInfiniteQuery.d.cts","names":[],"sources":["../../src/useInfiniteQuery.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsDgB,iBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,kCACP,cACA,QACA,OACA,WACA,aAEF,cAAc,cACb,8BAA8B,OAAO
|
|
1
|
+
{"version":3,"file":"useInfiniteQuery.d.cts","names":[],"sources":["../../src/useInfiniteQuery.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsDgB,iBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,kCACP,cACA,QACA,OACA,WACA,aAEF,cAAc,cACb,8BAA8B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6CxB,iBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,oCACP,cACA,QACA,OACA,WACA,aAEF,cAAc,cACb,uBAAuB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6CjB,iBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,wBACP,cACA,QACA,OACA,WACA,aAEF,cAAc,cACb,uBAAuB,OAAO"}
|
|
@@ -54,25 +54,27 @@ declare function useInfiniteQuery<TQueryFnData, TError = DefaultError, TData = I
|
|
|
54
54
|
*
|
|
55
55
|
* @example
|
|
56
56
|
* ```tsx
|
|
57
|
-
* import {
|
|
58
|
-
*
|
|
59
|
-
* const projectsOptions = infiniteQueryOptions({
|
|
60
|
-
* queryKey: ['projects'],
|
|
61
|
-
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
62
|
-
* initialPageParam: 0,
|
|
63
|
-
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
64
|
-
* })
|
|
57
|
+
* import { useInfiniteQuery } from '@tanstack/preact-query'
|
|
65
58
|
*
|
|
66
59
|
* function Projects() {
|
|
67
|
-
* const { data, fetchNextPage, hasNextPage, isFetchingNextPage } =
|
|
68
|
-
* useInfiniteQuery(
|
|
60
|
+
* const { data, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage } =
|
|
61
|
+
* useInfiniteQuery({
|
|
62
|
+
* queryKey: ['projects'],
|
|
63
|
+
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
64
|
+
* initialPageParam: 0,
|
|
65
|
+
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
66
|
+
* })
|
|
69
67
|
*
|
|
70
68
|
* return (
|
|
71
69
|
* <button
|
|
72
70
|
* onClick={() => fetchNextPage()}
|
|
73
|
-
* disabled={!hasNextPage ||
|
|
71
|
+
* disabled={!hasNextPage || isFetching}
|
|
74
72
|
* >
|
|
75
|
-
*
|
|
73
|
+
* {isFetchingNextPage
|
|
74
|
+
* ? 'Loading more...'
|
|
75
|
+
* : hasNextPage
|
|
76
|
+
* ? 'Load More'
|
|
77
|
+
* : 'Nothing more to load'}
|
|
76
78
|
* </button>
|
|
77
79
|
* )
|
|
78
80
|
* }
|
|
@@ -96,25 +98,27 @@ declare function useInfiniteQuery<TQueryFnData, TError = DefaultError, TData = I
|
|
|
96
98
|
*
|
|
97
99
|
* @example
|
|
98
100
|
* ```tsx
|
|
99
|
-
* import {
|
|
100
|
-
*
|
|
101
|
-
* const projectsOptions = infiniteQueryOptions({
|
|
102
|
-
* queryKey: ['projects'],
|
|
103
|
-
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
104
|
-
* initialPageParam: 0,
|
|
105
|
-
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
106
|
-
* })
|
|
101
|
+
* import { useInfiniteQuery } from '@tanstack/preact-query'
|
|
107
102
|
*
|
|
108
103
|
* function Projects() {
|
|
109
|
-
* const { data, fetchNextPage, hasNextPage, isFetchingNextPage } =
|
|
110
|
-
* useInfiniteQuery(
|
|
104
|
+
* const { data, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage } =
|
|
105
|
+
* useInfiniteQuery({
|
|
106
|
+
* queryKey: ['projects'],
|
|
107
|
+
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
108
|
+
* initialPageParam: 0,
|
|
109
|
+
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
110
|
+
* })
|
|
111
111
|
*
|
|
112
112
|
* return (
|
|
113
113
|
* <button
|
|
114
114
|
* onClick={() => fetchNextPage()}
|
|
115
|
-
* disabled={!hasNextPage ||
|
|
115
|
+
* disabled={!hasNextPage || isFetching}
|
|
116
116
|
* >
|
|
117
|
-
*
|
|
117
|
+
* {isFetchingNextPage
|
|
118
|
+
* ? 'Loading more...'
|
|
119
|
+
* : hasNextPage
|
|
120
|
+
* ? 'Load More'
|
|
121
|
+
* : 'Nothing more to load'}
|
|
118
122
|
* </button>
|
|
119
123
|
* )
|
|
120
124
|
* }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInfiniteQuery.d.ts","names":[],"sources":["../../src/useInfiniteQuery.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsDgB,iBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,kCACP,cACA,QACA,OACA,WACA,aAEF,cAAc,cACb,8BAA8B,OAAO
|
|
1
|
+
{"version":3,"file":"useInfiniteQuery.d.ts","names":[],"sources":["../../src/useInfiniteQuery.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsDgB,iBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,kCACP,cACA,QACA,OACA,WACA,aAEF,cAAc,cACb,8BAA8B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6CxB,iBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,oCACP,cACA,QACA,OACA,WACA,aAEF,cAAc,cACb,uBAAuB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6CjB,iBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,wBACP,cACA,QACA,OACA,WACA,aAEF,cAAc,cACb,uBAAuB,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInfiniteQuery.js","names":[],"sources":["../../src/useInfiniteQuery.ts"],"sourcesContent":["import { InfiniteQueryObserver } from '@tanstack/query-core'\nimport type {\n DefaultError,\n InfiniteData,\n QueryClient,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\n\nimport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infiniteQueryOptions'\nimport type {\n DefinedUseInfiniteQueryResult,\n UseInfiniteQueryOptions,\n UseInfiniteQueryResult,\n} from './types'\nimport { useBaseQuery } from './useBaseQuery'\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `queryFn`,\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * This overload is selected when `initialData` is set.\n *\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` set.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The same properties as `useQuery`, with the addition of `data.pages`, `data.pageParams`,\n * `fetchNextPage`, `fetchPreviousPage`, `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and\n * `isFetchingPreviousPage`.\n *\n * @example\n * ```tsx\n * import { useInfiniteQuery } from '@tanstack/preact-query'\n *\n * function Projects() {\n * const { data } = useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n *\n * return <>{data.pages.map((page) => page.projects.map((p) => <p key={p.id}>{p.name}</p>))}</>\n * }\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: QueryClient,\n): DefinedUseInfiniteQueryResult<TData, TError>\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `queryFn`,\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The same properties as `useQuery`, with the addition of `data.pages`, `data.pageParams`,\n * `fetchNextPage`, `fetchPreviousPage`, `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and\n * `isFetchingPreviousPage`.\n *\n * @example\n * ```tsx\n * import {
|
|
1
|
+
{"version":3,"file":"useInfiniteQuery.js","names":[],"sources":["../../src/useInfiniteQuery.ts"],"sourcesContent":["import { InfiniteQueryObserver } from '@tanstack/query-core'\nimport type {\n DefaultError,\n InfiniteData,\n QueryClient,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\n\nimport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infiniteQueryOptions'\nimport type {\n DefinedUseInfiniteQueryResult,\n UseInfiniteQueryOptions,\n UseInfiniteQueryResult,\n} from './types'\nimport { useBaseQuery } from './useBaseQuery'\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `queryFn`,\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * This overload is selected when `initialData` is set.\n *\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` set.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The same properties as `useQuery`, with the addition of `data.pages`, `data.pageParams`,\n * `fetchNextPage`, `fetchPreviousPage`, `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and\n * `isFetchingPreviousPage`.\n *\n * @example\n * ```tsx\n * import { useInfiniteQuery } from '@tanstack/preact-query'\n *\n * function Projects() {\n * const { data } = useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n *\n * return <>{data.pages.map((page) => page.projects.map((p) => <p key={p.id}>{p.name}</p>))}</>\n * }\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: QueryClient,\n): DefinedUseInfiniteQueryResult<TData, TError>\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `queryFn`,\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The same properties as `useQuery`, with the addition of `data.pages`, `data.pageParams`,\n * `fetchNextPage`, `fetchPreviousPage`, `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and\n * `isFetchingPreviousPage`.\n *\n * @example\n * ```tsx\n * import { useInfiniteQuery } from '@tanstack/preact-query'\n *\n * function Projects() {\n * const { data, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage } =\n * useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * return (\n * <button\n * onClick={() => fetchNextPage()}\n * disabled={!hasNextPage || isFetching}\n * >\n * {isFetchingNextPage\n * ? 'Loading more...'\n * : hasNextPage\n * ? 'Load More'\n * : 'Nothing more to load'}\n * </button>\n * )\n * }\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: QueryClient,\n): UseInfiniteQueryResult<TData, TError>\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `queryFn`,\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`.\n * @param options - The {@link UseInfiniteQueryOptions} to use — everything you can pass to `useInfiniteQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The same properties as `useQuery`, with the addition of `data.pages`, `data.pageParams`,\n * `fetchNextPage`, `fetchPreviousPage`, `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and\n * `isFetchingPreviousPage`.\n *\n * @example\n * ```tsx\n * import { useInfiniteQuery } from '@tanstack/preact-query'\n *\n * function Projects() {\n * const { data, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage } =\n * useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * return (\n * <button\n * onClick={() => fetchNextPage()}\n * disabled={!hasNextPage || isFetching}\n * >\n * {isFetchingNextPage\n * ? 'Loading more...'\n * : hasNextPage\n * ? 'Load More'\n * : 'Nothing more to load'}\n * </button>\n * )\n * }\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: QueryClient,\n): UseInfiniteQueryResult<TData, TError>\n\nexport function useInfiniteQuery(\n options: UseInfiniteQueryOptions,\n queryClient?: QueryClient,\n) {\n return useBaseQuery(\n options,\n InfiniteQueryObserver as typeof QueryObserver,\n queryClient,\n )\n}\n"],"mappings":";;;AA+LA,SAAgB,iBACd,SACA,aACA;CACA,OAAO,aACL,SACA,uBACA,WACF;AACF"}
|
|
@@ -23,6 +23,20 @@ let preact_hooks = require("preact/hooks");
|
|
|
23
23
|
* // How many queries matching the posts prefix are fetching?
|
|
24
24
|
* const isFetchingPosts = useIsFetching({ queryKey: ['posts'] })
|
|
25
25
|
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* A global loading indicator for any query fetching in the background, not just the ones on screen:
|
|
29
|
+
* ```tsx
|
|
30
|
+
* import { useIsFetching } from '@tanstack/preact-query'
|
|
31
|
+
*
|
|
32
|
+
* function GlobalLoadingIndicator() {
|
|
33
|
+
* const isFetching = useIsFetching()
|
|
34
|
+
*
|
|
35
|
+
* return isFetching ? (
|
|
36
|
+
* <div>Queries are fetching in the background...</div>
|
|
37
|
+
* ) : null
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
26
40
|
*/
|
|
27
41
|
function useIsFetching(filters, queryClient) {
|
|
28
42
|
const client = require_QueryClientProvider.useQueryClient(queryClient);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsFetching.cjs","names":["useQueryClient","useSyncExternalStore","useCallback","notifyManager"],"sources":["../../src/useIsFetching.ts"],"sourcesContent":["import { notifyManager } from '@tanstack/query-core'\nimport type { QueryClient, QueryFilters } from '@tanstack/query-core'\nimport { useCallback } from 'preact/hooks'\n\nimport { useQueryClient } from './QueryClientProvider'\nimport { useSyncExternalStore } from './utils'\n\n/**\n * `useIsFetching` is an optional hook that returns the `number` of the queries that your application is loading or\n * fetching in the background (useful for app-wide loading indicators).\n *\n * @param filters - The {@link QueryFilters} to narrow down the matched queries.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns Will be the `number` of the queries that your application is currently loading or fetching in the\n * background.\n *\n * @example\n * ```tsx\n * import { useIsFetching } from '@tanstack/preact-query'\n *\n * // How many queries are fetching?\n * const isFetching = useIsFetching()\n * // How many queries matching the posts prefix are fetching?\n * const isFetchingPosts = useIsFetching({ queryKey: ['posts'] })\n * ```\n */\nexport function useIsFetching(\n filters?: QueryFilters,\n queryClient?: QueryClient,\n): number {\n const client = useQueryClient(queryClient)\n const queryCache = client.getQueryCache()\n\n return useSyncExternalStore(\n useCallback(\n (onStoreChange) =>\n queryCache.subscribe(notifyManager.batchCalls(onStoreChange)),\n [queryCache],\n ),\n () => client.isFetching(filters),\n )\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIsFetching.cjs","names":["useQueryClient","useSyncExternalStore","useCallback","notifyManager"],"sources":["../../src/useIsFetching.ts"],"sourcesContent":["import { notifyManager } from '@tanstack/query-core'\nimport type { QueryClient, QueryFilters } from '@tanstack/query-core'\nimport { useCallback } from 'preact/hooks'\n\nimport { useQueryClient } from './QueryClientProvider'\nimport { useSyncExternalStore } from './utils'\n\n/**\n * `useIsFetching` is an optional hook that returns the `number` of the queries that your application is loading or\n * fetching in the background (useful for app-wide loading indicators).\n *\n * @param filters - The {@link QueryFilters} to narrow down the matched queries.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns Will be the `number` of the queries that your application is currently loading or fetching in the\n * background.\n *\n * @example\n * ```tsx\n * import { useIsFetching } from '@tanstack/preact-query'\n *\n * // How many queries are fetching?\n * const isFetching = useIsFetching()\n * // How many queries matching the posts prefix are fetching?\n * const isFetchingPosts = useIsFetching({ queryKey: ['posts'] })\n * ```\n *\n * @example\n * A global loading indicator for any query fetching in the background, not just the ones on screen:\n * ```tsx\n * import { useIsFetching } from '@tanstack/preact-query'\n *\n * function GlobalLoadingIndicator() {\n * const isFetching = useIsFetching()\n *\n * return isFetching ? (\n * <div>Queries are fetching in the background...</div>\n * ) : null\n * }\n * ```\n */\nexport function useIsFetching(\n filters?: QueryFilters,\n queryClient?: QueryClient,\n): number {\n const client = useQueryClient(queryClient)\n const queryCache = client.getQueryCache()\n\n return useSyncExternalStore(\n useCallback(\n (onStoreChange) =>\n queryCache.subscribe(notifyManager.batchCalls(onStoreChange)),\n [queryCache],\n ),\n () => client.isFetching(filters),\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,cACd,SACA,aACQ;CACR,MAAM,SAASA,4BAAAA,eAAe,WAAW;CACzC,MAAM,aAAa,OAAO,cAAc;CAExC,OAAOC,cAAAA,sBAAAA,GACLC,aAAAA,YAAAA,EACG,kBACC,WAAW,UAAUC,qBAAAA,cAAc,WAAW,aAAa,CAAC,GAC9D,CAAC,UAAU,CACb,SACM,OAAO,WAAW,OAAO,CACjC;AACF"}
|
|
@@ -19,6 +19,20 @@ import { QueryClient, QueryFilters } from "@tanstack/query-core";
|
|
|
19
19
|
* // How many queries matching the posts prefix are fetching?
|
|
20
20
|
* const isFetchingPosts = useIsFetching({ queryKey: ['posts'] })
|
|
21
21
|
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* A global loading indicator for any query fetching in the background, not just the ones on screen:
|
|
25
|
+
* ```tsx
|
|
26
|
+
* import { useIsFetching } from '@tanstack/preact-query'
|
|
27
|
+
*
|
|
28
|
+
* function GlobalLoadingIndicator() {
|
|
29
|
+
* const isFetching = useIsFetching()
|
|
30
|
+
*
|
|
31
|
+
* return isFetching ? (
|
|
32
|
+
* <div>Queries are fetching in the background...</div>
|
|
33
|
+
* ) : null
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
22
36
|
*/
|
|
23
37
|
declare function useIsFetching(filters?: QueryFilters, queryClient?: QueryClient): number;
|
|
24
38
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsFetching.d.cts","names":[],"sources":["../../src/useIsFetching.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIsFetching.d.cts","names":[],"sources":["../../src/useIsFetching.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyCgB,cACd,UAAU,cACV,cAAc"}
|
|
@@ -19,6 +19,20 @@ import { QueryClient, QueryFilters } from "@tanstack/query-core";
|
|
|
19
19
|
* // How many queries matching the posts prefix are fetching?
|
|
20
20
|
* const isFetchingPosts = useIsFetching({ queryKey: ['posts'] })
|
|
21
21
|
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* A global loading indicator for any query fetching in the background, not just the ones on screen:
|
|
25
|
+
* ```tsx
|
|
26
|
+
* import { useIsFetching } from '@tanstack/preact-query'
|
|
27
|
+
*
|
|
28
|
+
* function GlobalLoadingIndicator() {
|
|
29
|
+
* const isFetching = useIsFetching()
|
|
30
|
+
*
|
|
31
|
+
* return isFetching ? (
|
|
32
|
+
* <div>Queries are fetching in the background...</div>
|
|
33
|
+
* ) : null
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
22
36
|
*/
|
|
23
37
|
declare function useIsFetching(filters?: QueryFilters, queryClient?: QueryClient): number;
|
|
24
38
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsFetching.d.ts","names":[],"sources":["../../src/useIsFetching.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIsFetching.d.ts","names":[],"sources":["../../src/useIsFetching.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyCgB,cACd,UAAU,cACV,cAAc"}
|
|
@@ -22,6 +22,20 @@ import { useCallback } from "preact/hooks";
|
|
|
22
22
|
* // How many queries matching the posts prefix are fetching?
|
|
23
23
|
* const isFetchingPosts = useIsFetching({ queryKey: ['posts'] })
|
|
24
24
|
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* A global loading indicator for any query fetching in the background, not just the ones on screen:
|
|
28
|
+
* ```tsx
|
|
29
|
+
* import { useIsFetching } from '@tanstack/preact-query'
|
|
30
|
+
*
|
|
31
|
+
* function GlobalLoadingIndicator() {
|
|
32
|
+
* const isFetching = useIsFetching()
|
|
33
|
+
*
|
|
34
|
+
* return isFetching ? (
|
|
35
|
+
* <div>Queries are fetching in the background...</div>
|
|
36
|
+
* ) : null
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
25
39
|
*/
|
|
26
40
|
function useIsFetching(filters, queryClient) {
|
|
27
41
|
const client = useQueryClient(queryClient);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsFetching.js","names":[],"sources":["../../src/useIsFetching.ts"],"sourcesContent":["import { notifyManager } from '@tanstack/query-core'\nimport type { QueryClient, QueryFilters } from '@tanstack/query-core'\nimport { useCallback } from 'preact/hooks'\n\nimport { useQueryClient } from './QueryClientProvider'\nimport { useSyncExternalStore } from './utils'\n\n/**\n * `useIsFetching` is an optional hook that returns the `number` of the queries that your application is loading or\n * fetching in the background (useful for app-wide loading indicators).\n *\n * @param filters - The {@link QueryFilters} to narrow down the matched queries.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns Will be the `number` of the queries that your application is currently loading or fetching in the\n * background.\n *\n * @example\n * ```tsx\n * import { useIsFetching } from '@tanstack/preact-query'\n *\n * // How many queries are fetching?\n * const isFetching = useIsFetching()\n * // How many queries matching the posts prefix are fetching?\n * const isFetchingPosts = useIsFetching({ queryKey: ['posts'] })\n * ```\n */\nexport function useIsFetching(\n filters?: QueryFilters,\n queryClient?: QueryClient,\n): number {\n const client = useQueryClient(queryClient)\n const queryCache = client.getQueryCache()\n\n return useSyncExternalStore(\n useCallback(\n (onStoreChange) =>\n queryCache.subscribe(notifyManager.batchCalls(onStoreChange)),\n [queryCache],\n ),\n () => client.isFetching(filters),\n )\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIsFetching.js","names":[],"sources":["../../src/useIsFetching.ts"],"sourcesContent":["import { notifyManager } from '@tanstack/query-core'\nimport type { QueryClient, QueryFilters } from '@tanstack/query-core'\nimport { useCallback } from 'preact/hooks'\n\nimport { useQueryClient } from './QueryClientProvider'\nimport { useSyncExternalStore } from './utils'\n\n/**\n * `useIsFetching` is an optional hook that returns the `number` of the queries that your application is loading or\n * fetching in the background (useful for app-wide loading indicators).\n *\n * @param filters - The {@link QueryFilters} to narrow down the matched queries.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns Will be the `number` of the queries that your application is currently loading or fetching in the\n * background.\n *\n * @example\n * ```tsx\n * import { useIsFetching } from '@tanstack/preact-query'\n *\n * // How many queries are fetching?\n * const isFetching = useIsFetching()\n * // How many queries matching the posts prefix are fetching?\n * const isFetchingPosts = useIsFetching({ queryKey: ['posts'] })\n * ```\n *\n * @example\n * A global loading indicator for any query fetching in the background, not just the ones on screen:\n * ```tsx\n * import { useIsFetching } from '@tanstack/preact-query'\n *\n * function GlobalLoadingIndicator() {\n * const isFetching = useIsFetching()\n *\n * return isFetching ? (\n * <div>Queries are fetching in the background...</div>\n * ) : null\n * }\n * ```\n */\nexport function useIsFetching(\n filters?: QueryFilters,\n queryClient?: QueryClient,\n): number {\n const client = useQueryClient(queryClient)\n const queryCache = client.getQueryCache()\n\n return useSyncExternalStore(\n useCallback(\n (onStoreChange) =>\n queryCache.subscribe(notifyManager.batchCalls(onStoreChange)),\n [queryCache],\n ),\n () => client.isFetching(filters),\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,cACd,SACA,aACQ;CACR,MAAM,SAAS,eAAe,WAAW;CACzC,MAAM,aAAa,OAAO,cAAc;CAExC,OAAO,qBACL,aACG,kBACC,WAAW,UAAU,cAAc,WAAW,aAAa,CAAC,GAC9D,CAAC,UAAU,CACb,SACM,OAAO,WAAW,OAAO,CACjC;AACF"}
|