@tanstack/react-query 4.13.5 → 4.14.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/QueryClientProvider.esm.js +5 -0
- package/build/lib/QueryClientProvider.esm.js.map +1 -1
- package/build/lib/QueryClientProvider.js +5 -0
- package/build/lib/QueryClientProvider.js.map +1 -1
- package/build/lib/QueryClientProvider.mjs +5 -0
- package/build/lib/QueryClientProvider.mjs.map +1 -1
- package/build/umd/index.development.js +16 -3
- 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 +2 -2
- package/src/QueryClientProvider.tsx +8 -0
- package/src/__tests__/ssr-hydration.test.tsx +24 -4
- package/src/__tests__/useQuery.test.tsx +80 -13
|
@@ -48,6 +48,11 @@ const QueryClientProvider = ({
|
|
|
48
48
|
client.unmount();
|
|
49
49
|
};
|
|
50
50
|
}, [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
|
+
|
|
51
56
|
const Context = getQueryClientContext(context, contextSharing);
|
|
52
57
|
return /*#__PURE__*/React.createElement(QueryClientSharingContext.Provider, {
|
|
53
58
|
value: !context && contextSharing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClientProvider.esm.js","sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\nimport type { ContextOptions } from './types'\n\ndeclare global {\n interface Window {\n ReactQueryClientContext?: React.Context<QueryClient | undefined>\n }\n}\n\nexport const defaultContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\nconst QueryClientSharingContext = React.createContext<boolean>(false)\n\n// If we are given a context, we will use it.\n// Otherwise, if contextSharing is on, we share the first and at least one\n// instance of the context across the window\n// to ensure that if React Query is used across\n// different bundles or microfrontends they will\n// all use the same **instance** of context, regardless\n// of module scoping.\nfunction getQueryClientContext(\n context: React.Context<QueryClient | undefined> | undefined,\n contextSharing: boolean,\n) {\n if (context) {\n return context\n }\n if (contextSharing && typeof window !== 'undefined') {\n if (!window.ReactQueryClientContext) {\n window.ReactQueryClientContext = defaultContext\n }\n\n return window.ReactQueryClientContext\n }\n\n return defaultContext\n}\n\nexport const useQueryClient = ({ context }: ContextOptions = {}) => {\n const queryClient = React.useContext(\n getQueryClientContext(context, React.useContext(QueryClientSharingContext)),\n )\n\n if (!queryClient) {\n throw new Error('No QueryClient set, use QueryClientProvider to set one')\n }\n\n return queryClient\n}\n\ntype QueryClientProviderPropsBase = {\n client: QueryClient\n children?: React.ReactNode\n}\ntype QueryClientProviderPropsWithContext = ContextOptions & {\n contextSharing?: never\n} & QueryClientProviderPropsBase\ntype QueryClientProviderPropsWithContextSharing = {\n context?: never\n contextSharing?: boolean\n} & QueryClientProviderPropsBase\n\nexport type QueryClientProviderProps =\n | QueryClientProviderPropsWithContext\n | QueryClientProviderPropsWithContextSharing\n\nexport const QueryClientProvider = ({\n client,\n children,\n context,\n contextSharing = false,\n}: QueryClientProviderProps): JSX.Element => {\n React.useEffect(() => {\n client.mount()\n return () => {\n client.unmount()\n }\n }, [client])\n\n const Context = getQueryClientContext(context, contextSharing)\n\n return (\n <QueryClientSharingContext.Provider value={!context && contextSharing}>\n <Context.Provider value={client}>{children}</Context.Provider>\n </QueryClientSharingContext.Provider>\n )\n}\n"],"names":["defaultContext","React","createContext","undefined","QueryClientSharingContext","getQueryClientContext","context","contextSharing","window","ReactQueryClientContext","useQueryClient","queryClient","useContext","Error","QueryClientProvider","client","children","useEffect","mount","unmount","Context"],"mappings":";;AAWO,MAAMA,cAAc,gBAAGC,KAAK,CAACC,aAAN,CAC5BC,SAD4B,EAAvB;AAGP,MAAMC,yBAAyB,gBAAGH,KAAK,CAACC,aAAN,CAA6B,KAA7B,CAAlC;AAGA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASG,qBAAT,CACEC,OADF,EAEEC,cAFF,EAGE;AACA,EAAA,IAAID,OAAJ,EAAa;AACX,IAAA,OAAOA,OAAP,CAAA;AACD,GAAA;;AACD,EAAA,IAAIC,cAAc,IAAI,OAAOC,MAAP,KAAkB,WAAxC,EAAqD;AACnD,IAAA,IAAI,CAACA,MAAM,CAACC,uBAAZ,EAAqC;MACnCD,MAAM,CAACC,uBAAP,GAAiCT,cAAjC,CAAA;AACD,KAAA;;IAED,OAAOQ,MAAM,CAACC,uBAAd,CAAA;AACD,GAAA;;AAED,EAAA,OAAOT,cAAP,CAAA;AACD,CAAA;;AAEM,MAAMU,cAAc,GAAG,CAAC;AAAEJ,EAAAA,OAAAA;AAAF,CAAA,GAA8B,EAA/B,KAAsC;AAClE,EAAA,MAAMK,WAAW,GAAGV,KAAK,CAACW,UAAN,CAClBP,qBAAqB,CAACC,OAAD,EAAUL,KAAK,CAACW,UAAN,CAAiBR,yBAAjB,CAAV,CADH,CAApB,CAAA;;EAIA,IAAI,CAACO,WAAL,EAAkB;AAChB,IAAA,MAAM,IAAIE,KAAJ,CAAU,wDAAV,CAAN,CAAA;AACD,GAAA;;AAED,EAAA,OAAOF,WAAP,CAAA;AACD,EAVM;AA4BA,MAAMG,mBAAmB,GAAG,CAAC;EAClCC,MADkC;EAElCC,QAFkC;EAGlCV,OAHkC;AAIlCC,EAAAA,cAAc,GAAG,KAAA;AAJiB,CAAD,KAKU;EAC3CN,KAAK,CAACgB,SAAN,CAAgB,MAAM;AACpBF,IAAAA,MAAM,CAACG,KAAP,EAAA,CAAA;AACA,IAAA,OAAO,MAAM;AACXH,MAAAA,MAAM,CAACI,OAAP,EAAA,CAAA;KADF,CAAA;GAFF,EAKG,CAACJ,MAAD,CALH,CAAA,CAAA;
|
|
1
|
+
{"version":3,"file":"QueryClientProvider.esm.js","sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\nimport type { ContextOptions } from './types'\n\ndeclare global {\n interface Window {\n ReactQueryClientContext?: React.Context<QueryClient | undefined>\n }\n}\n\nexport const defaultContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\nconst QueryClientSharingContext = React.createContext<boolean>(false)\n\n// If we are given a context, we will use it.\n// Otherwise, if contextSharing is on, we share the first and at least one\n// instance of the context across the window\n// to ensure that if React Query is used across\n// different bundles or microfrontends they will\n// all use the same **instance** of context, regardless\n// of module scoping.\nfunction getQueryClientContext(\n context: React.Context<QueryClient | undefined> | undefined,\n contextSharing: boolean,\n) {\n if (context) {\n return context\n }\n if (contextSharing && typeof window !== 'undefined') {\n if (!window.ReactQueryClientContext) {\n window.ReactQueryClientContext = defaultContext\n }\n\n return window.ReactQueryClientContext\n }\n\n return defaultContext\n}\n\nexport const useQueryClient = ({ context }: ContextOptions = {}) => {\n const queryClient = React.useContext(\n getQueryClientContext(context, React.useContext(QueryClientSharingContext)),\n )\n\n if (!queryClient) {\n throw new Error('No QueryClient set, use QueryClientProvider to set one')\n }\n\n return queryClient\n}\n\ntype QueryClientProviderPropsBase = {\n client: QueryClient\n children?: React.ReactNode\n}\ntype QueryClientProviderPropsWithContext = ContextOptions & {\n contextSharing?: never\n} & QueryClientProviderPropsBase\ntype QueryClientProviderPropsWithContextSharing = {\n context?: never\n contextSharing?: boolean\n} & QueryClientProviderPropsBase\n\nexport type QueryClientProviderProps =\n | QueryClientProviderPropsWithContext\n | QueryClientProviderPropsWithContextSharing\n\nexport const QueryClientProvider = ({\n client,\n children,\n context,\n contextSharing = false,\n}: QueryClientProviderProps): JSX.Element => {\n React.useEffect(() => {\n client.mount()\n return () => {\n client.unmount()\n }\n }, [client])\n\n if (process.env.NODE_ENV !== 'production' && contextSharing) {\n client\n .getLogger()\n .error(\n `The contextSharing option has been deprecated and will be removed in the next major version`,\n )\n }\n\n const Context = getQueryClientContext(context, contextSharing)\n\n return (\n <QueryClientSharingContext.Provider value={!context && contextSharing}>\n <Context.Provider value={client}>{children}</Context.Provider>\n </QueryClientSharingContext.Provider>\n )\n}\n"],"names":["defaultContext","React","createContext","undefined","QueryClientSharingContext","getQueryClientContext","context","contextSharing","window","ReactQueryClientContext","useQueryClient","queryClient","useContext","Error","QueryClientProvider","client","children","useEffect","mount","unmount","process","env","NODE_ENV","getLogger","error","Context"],"mappings":";;AAWO,MAAMA,cAAc,gBAAGC,KAAK,CAACC,aAAN,CAC5BC,SAD4B,EAAvB;AAGP,MAAMC,yBAAyB,gBAAGH,KAAK,CAACC,aAAN,CAA6B,KAA7B,CAAlC;AAGA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASG,qBAAT,CACEC,OADF,EAEEC,cAFF,EAGE;AACA,EAAA,IAAID,OAAJ,EAAa;AACX,IAAA,OAAOA,OAAP,CAAA;AACD,GAAA;;AACD,EAAA,IAAIC,cAAc,IAAI,OAAOC,MAAP,KAAkB,WAAxC,EAAqD;AACnD,IAAA,IAAI,CAACA,MAAM,CAACC,uBAAZ,EAAqC;MACnCD,MAAM,CAACC,uBAAP,GAAiCT,cAAjC,CAAA;AACD,KAAA;;IAED,OAAOQ,MAAM,CAACC,uBAAd,CAAA;AACD,GAAA;;AAED,EAAA,OAAOT,cAAP,CAAA;AACD,CAAA;;AAEM,MAAMU,cAAc,GAAG,CAAC;AAAEJ,EAAAA,OAAAA;AAAF,CAAA,GAA8B,EAA/B,KAAsC;AAClE,EAAA,MAAMK,WAAW,GAAGV,KAAK,CAACW,UAAN,CAClBP,qBAAqB,CAACC,OAAD,EAAUL,KAAK,CAACW,UAAN,CAAiBR,yBAAjB,CAAV,CADH,CAApB,CAAA;;EAIA,IAAI,CAACO,WAAL,EAAkB;AAChB,IAAA,MAAM,IAAIE,KAAJ,CAAU,wDAAV,CAAN,CAAA;AACD,GAAA;;AAED,EAAA,OAAOF,WAAP,CAAA;AACD,EAVM;AA4BA,MAAMG,mBAAmB,GAAG,CAAC;EAClCC,MADkC;EAElCC,QAFkC;EAGlCV,OAHkC;AAIlCC,EAAAA,cAAc,GAAG,KAAA;AAJiB,CAAD,KAKU;EAC3CN,KAAK,CAACgB,SAAN,CAAgB,MAAM;AACpBF,IAAAA,MAAM,CAACG,KAAP,EAAA,CAAA;AACA,IAAA,OAAO,MAAM;AACXH,MAAAA,MAAM,CAACI,OAAP,EAAA,CAAA;KADF,CAAA;GAFF,EAKG,CAACJ,MAAD,CALH,CAAA,CAAA;;EAOA,IAAIK,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAAzB,IAAyCf,cAA7C,EAA6D;IAC3DQ,MAAM,CACHQ,SADH,EAAA,CAEGC,KAFH,CAAA,6FAAA,CAAA,CAAA;AAKD,GAAA;;AAED,EAAA,MAAMC,OAAO,GAAGpB,qBAAqB,CAACC,OAAD,EAAUC,cAAV,CAArC,CAAA;EAEA,oBACE,KAAA,CAAA,aAAA,CAAC,yBAAD,CAA2B,QAA3B,EAAA;IAAoC,KAAK,EAAE,CAACD,OAAD,IAAYC,cAAAA;GACrD,eAAA,KAAA,CAAA,aAAA,CAAC,OAAD,CAAS,QAAT,EAAA;AAAkB,IAAA,KAAK,EAAEQ,MAAAA;GAASC,EAAAA,QAAlC,CADF,CADF,CAAA;AAKD;;;;"}
|
|
@@ -72,6 +72,11 @@ const QueryClientProvider = ({
|
|
|
72
72
|
client.unmount();
|
|
73
73
|
};
|
|
74
74
|
}, [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
|
+
|
|
75
80
|
const Context = getQueryClientContext(context, contextSharing);
|
|
76
81
|
return /*#__PURE__*/React__namespace.createElement(QueryClientSharingContext.Provider, {
|
|
77
82
|
value: !context && contextSharing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClientProvider.js","sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\nimport type { ContextOptions } from './types'\n\ndeclare global {\n interface Window {\n ReactQueryClientContext?: React.Context<QueryClient | undefined>\n }\n}\n\nexport const defaultContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\nconst QueryClientSharingContext = React.createContext<boolean>(false)\n\n// If we are given a context, we will use it.\n// Otherwise, if contextSharing is on, we share the first and at least one\n// instance of the context across the window\n// to ensure that if React Query is used across\n// different bundles or microfrontends they will\n// all use the same **instance** of context, regardless\n// of module scoping.\nfunction getQueryClientContext(\n context: React.Context<QueryClient | undefined> | undefined,\n contextSharing: boolean,\n) {\n if (context) {\n return context\n }\n if (contextSharing && typeof window !== 'undefined') {\n if (!window.ReactQueryClientContext) {\n window.ReactQueryClientContext = defaultContext\n }\n\n return window.ReactQueryClientContext\n }\n\n return defaultContext\n}\n\nexport const useQueryClient = ({ context }: ContextOptions = {}) => {\n const queryClient = React.useContext(\n getQueryClientContext(context, React.useContext(QueryClientSharingContext)),\n )\n\n if (!queryClient) {\n throw new Error('No QueryClient set, use QueryClientProvider to set one')\n }\n\n return queryClient\n}\n\ntype QueryClientProviderPropsBase = {\n client: QueryClient\n children?: React.ReactNode\n}\ntype QueryClientProviderPropsWithContext = ContextOptions & {\n contextSharing?: never\n} & QueryClientProviderPropsBase\ntype QueryClientProviderPropsWithContextSharing = {\n context?: never\n contextSharing?: boolean\n} & QueryClientProviderPropsBase\n\nexport type QueryClientProviderProps =\n | QueryClientProviderPropsWithContext\n | QueryClientProviderPropsWithContextSharing\n\nexport const QueryClientProvider = ({\n client,\n children,\n context,\n contextSharing = false,\n}: QueryClientProviderProps): JSX.Element => {\n React.useEffect(() => {\n client.mount()\n return () => {\n client.unmount()\n }\n }, [client])\n\n const Context = getQueryClientContext(context, contextSharing)\n\n return (\n <QueryClientSharingContext.Provider value={!context && contextSharing}>\n <Context.Provider value={client}>{children}</Context.Provider>\n </QueryClientSharingContext.Provider>\n )\n}\n"],"names":["defaultContext","React","createContext","undefined","QueryClientSharingContext","getQueryClientContext","context","contextSharing","window","ReactQueryClientContext","useQueryClient","queryClient","useContext","Error","QueryClientProvider","client","children","useEffect","mount","unmount","Context"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAWO,MAAMA,cAAc,gBAAGC,gBAAK,CAACC,aAAN,CAC5BC,SAD4B,EAAvB;AAGP,MAAMC,yBAAyB,gBAAGH,gBAAK,CAACC,aAAN,CAA6B,KAA7B,CAAlC;AAGA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASG,qBAAT,CACEC,OADF,EAEEC,cAFF,EAGE;AACA,EAAA,IAAID,OAAJ,EAAa;AACX,IAAA,OAAOA,OAAP,CAAA;AACD,GAAA;;AACD,EAAA,IAAIC,cAAc,IAAI,OAAOC,MAAP,KAAkB,WAAxC,EAAqD;AACnD,IAAA,IAAI,CAACA,MAAM,CAACC,uBAAZ,EAAqC;MACnCD,MAAM,CAACC,uBAAP,GAAiCT,cAAjC,CAAA;AACD,KAAA;;IAED,OAAOQ,MAAM,CAACC,uBAAd,CAAA;AACD,GAAA;;AAED,EAAA,OAAOT,cAAP,CAAA;AACD,CAAA;;AAEM,MAAMU,cAAc,GAAG,CAAC;AAAEJ,EAAAA,OAAAA;AAAF,CAAA,GAA8B,EAA/B,KAAsC;AAClE,EAAA,MAAMK,WAAW,GAAGV,gBAAK,CAACW,UAAN,CAClBP,qBAAqB,CAACC,OAAD,EAAUL,gBAAK,CAACW,UAAN,CAAiBR,yBAAjB,CAAV,CADH,CAApB,CAAA;;EAIA,IAAI,CAACO,WAAL,EAAkB;AAChB,IAAA,MAAM,IAAIE,KAAJ,CAAU,wDAAV,CAAN,CAAA;AACD,GAAA;;AAED,EAAA,OAAOF,WAAP,CAAA;AACD,EAVM;AA4BA,MAAMG,mBAAmB,GAAG,CAAC;EAClCC,MADkC;EAElCC,QAFkC;EAGlCV,OAHkC;AAIlCC,EAAAA,cAAc,GAAG,KAAA;AAJiB,CAAD,KAKU;EAC3CN,gBAAK,CAACgB,SAAN,CAAgB,MAAM;AACpBF,IAAAA,MAAM,CAACG,KAAP,EAAA,CAAA;AACA,IAAA,OAAO,MAAM;AACXH,MAAAA,MAAM,CAACI,OAAP,EAAA,CAAA;KADF,CAAA;GAFF,EAKG,CAACJ,MAAD,CALH,CAAA,CAAA;
|
|
1
|
+
{"version":3,"file":"QueryClientProvider.js","sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\nimport type { ContextOptions } from './types'\n\ndeclare global {\n interface Window {\n ReactQueryClientContext?: React.Context<QueryClient | undefined>\n }\n}\n\nexport const defaultContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\nconst QueryClientSharingContext = React.createContext<boolean>(false)\n\n// If we are given a context, we will use it.\n// Otherwise, if contextSharing is on, we share the first and at least one\n// instance of the context across the window\n// to ensure that if React Query is used across\n// different bundles or microfrontends they will\n// all use the same **instance** of context, regardless\n// of module scoping.\nfunction getQueryClientContext(\n context: React.Context<QueryClient | undefined> | undefined,\n contextSharing: boolean,\n) {\n if (context) {\n return context\n }\n if (contextSharing && typeof window !== 'undefined') {\n if (!window.ReactQueryClientContext) {\n window.ReactQueryClientContext = defaultContext\n }\n\n return window.ReactQueryClientContext\n }\n\n return defaultContext\n}\n\nexport const useQueryClient = ({ context }: ContextOptions = {}) => {\n const queryClient = React.useContext(\n getQueryClientContext(context, React.useContext(QueryClientSharingContext)),\n )\n\n if (!queryClient) {\n throw new Error('No QueryClient set, use QueryClientProvider to set one')\n }\n\n return queryClient\n}\n\ntype QueryClientProviderPropsBase = {\n client: QueryClient\n children?: React.ReactNode\n}\ntype QueryClientProviderPropsWithContext = ContextOptions & {\n contextSharing?: never\n} & QueryClientProviderPropsBase\ntype QueryClientProviderPropsWithContextSharing = {\n context?: never\n contextSharing?: boolean\n} & QueryClientProviderPropsBase\n\nexport type QueryClientProviderProps =\n | QueryClientProviderPropsWithContext\n | QueryClientProviderPropsWithContextSharing\n\nexport const QueryClientProvider = ({\n client,\n children,\n context,\n contextSharing = false,\n}: QueryClientProviderProps): JSX.Element => {\n React.useEffect(() => {\n client.mount()\n return () => {\n client.unmount()\n }\n }, [client])\n\n if (process.env.NODE_ENV !== 'production' && contextSharing) {\n client\n .getLogger()\n .error(\n `The contextSharing option has been deprecated and will be removed in the next major version`,\n )\n }\n\n const Context = getQueryClientContext(context, contextSharing)\n\n return (\n <QueryClientSharingContext.Provider value={!context && contextSharing}>\n <Context.Provider value={client}>{children}</Context.Provider>\n </QueryClientSharingContext.Provider>\n )\n}\n"],"names":["defaultContext","React","createContext","undefined","QueryClientSharingContext","getQueryClientContext","context","contextSharing","window","ReactQueryClientContext","useQueryClient","queryClient","useContext","Error","QueryClientProvider","client","children","useEffect","mount","unmount","process","env","NODE_ENV","getLogger","error","Context"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAWO,MAAMA,cAAc,gBAAGC,gBAAK,CAACC,aAAN,CAC5BC,SAD4B,EAAvB;AAGP,MAAMC,yBAAyB,gBAAGH,gBAAK,CAACC,aAAN,CAA6B,KAA7B,CAAlC;AAGA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASG,qBAAT,CACEC,OADF,EAEEC,cAFF,EAGE;AACA,EAAA,IAAID,OAAJ,EAAa;AACX,IAAA,OAAOA,OAAP,CAAA;AACD,GAAA;;AACD,EAAA,IAAIC,cAAc,IAAI,OAAOC,MAAP,KAAkB,WAAxC,EAAqD;AACnD,IAAA,IAAI,CAACA,MAAM,CAACC,uBAAZ,EAAqC;MACnCD,MAAM,CAACC,uBAAP,GAAiCT,cAAjC,CAAA;AACD,KAAA;;IAED,OAAOQ,MAAM,CAACC,uBAAd,CAAA;AACD,GAAA;;AAED,EAAA,OAAOT,cAAP,CAAA;AACD,CAAA;;AAEM,MAAMU,cAAc,GAAG,CAAC;AAAEJ,EAAAA,OAAAA;AAAF,CAAA,GAA8B,EAA/B,KAAsC;AAClE,EAAA,MAAMK,WAAW,GAA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.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
|
+
|
|
51
56
|
const Context = getQueryClientContext(context, contextSharing);
|
|
52
57
|
return /*#__PURE__*/React.createElement(QueryClientSharingContext.Provider, {
|
|
53
58
|
value: !context && contextSharing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClientProvider.mjs","sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\nimport type { ContextOptions } from './types'\n\ndeclare global {\n interface Window {\n ReactQueryClientContext?: React.Context<QueryClient | undefined>\n }\n}\n\nexport const defaultContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\nconst QueryClientSharingContext = React.createContext<boolean>(false)\n\n// If we are given a context, we will use it.\n// Otherwise, if contextSharing is on, we share the first and at least one\n// instance of the context across the window\n// to ensure that if React Query is used across\n// different bundles or microfrontends they will\n// all use the same **instance** of context, regardless\n// of module scoping.\nfunction getQueryClientContext(\n context: React.Context<QueryClient | undefined> | undefined,\n contextSharing: boolean,\n) {\n if (context) {\n return context\n }\n if (contextSharing && typeof window !== 'undefined') {\n if (!window.ReactQueryClientContext) {\n window.ReactQueryClientContext = defaultContext\n }\n\n return window.ReactQueryClientContext\n }\n\n return defaultContext\n}\n\nexport const useQueryClient = ({ context }: ContextOptions = {}) => {\n const queryClient = React.useContext(\n getQueryClientContext(context, React.useContext(QueryClientSharingContext)),\n )\n\n if (!queryClient) {\n throw new Error('No QueryClient set, use QueryClientProvider to set one')\n }\n\n return queryClient\n}\n\ntype QueryClientProviderPropsBase = {\n client: QueryClient\n children?: React.ReactNode\n}\ntype QueryClientProviderPropsWithContext = ContextOptions & {\n contextSharing?: never\n} & QueryClientProviderPropsBase\ntype QueryClientProviderPropsWithContextSharing = {\n context?: never\n contextSharing?: boolean\n} & QueryClientProviderPropsBase\n\nexport type QueryClientProviderProps =\n | QueryClientProviderPropsWithContext\n | QueryClientProviderPropsWithContextSharing\n\nexport const QueryClientProvider = ({\n client,\n children,\n context,\n contextSharing = false,\n}: QueryClientProviderProps): JSX.Element => {\n React.useEffect(() => {\n client.mount()\n return () => {\n client.unmount()\n }\n }, [client])\n\n const Context = getQueryClientContext(context, contextSharing)\n\n return (\n <QueryClientSharingContext.Provider value={!context && contextSharing}>\n <Context.Provider value={client}>{children}</Context.Provider>\n </QueryClientSharingContext.Provider>\n )\n}\n"],"names":["defaultContext","React","createContext","undefined","QueryClientSharingContext","getQueryClientContext","context","contextSharing","window","ReactQueryClientContext","useQueryClient","queryClient","useContext","Error","QueryClientProvider","client","children","useEffect","mount","unmount","Context"],"mappings":";;AAWO,MAAMA,cAAc,gBAAGC,KAAK,CAACC,aAAN,CAC5BC,SAD4B,EAAvB;AAGP,MAAMC,yBAAyB,gBAAGH,KAAK,CAACC,aAAN,CAA6B,KAA7B,CAAlC;AAGA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASG,qBAAT,CACEC,OADF,EAEEC,cAFF,EAGE;AACA,EAAA,IAAID,OAAJ,EAAa;AACX,IAAA,OAAOA,OAAP,CAAA;AACD,GAAA;;AACD,EAAA,IAAIC,cAAc,IAAI,OAAOC,MAAP,KAAkB,WAAxC,EAAqD;AACnD,IAAA,IAAI,CAACA,MAAM,CAACC,uBAAZ,EAAqC;MACnCD,MAAM,CAACC,uBAAP,GAAiCT,cAAjC,CAAA;AACD,KAAA;;IAED,OAAOQ,MAAM,CAACC,uBAAd,CAAA;AACD,GAAA;;AAED,EAAA,OAAOT,cAAP,CAAA;AACD,CAAA;;AAEM,MAAMU,cAAc,GAAG,CAAC;AAAEJ,EAAAA,OAAAA;AAAF,CAAA,GAA8B,EAA/B,KAAsC;AAClE,EAAA,MAAMK,WAAW,GAAGV,KAAK,CAACW,UAAN,CAClBP,qBAAqB,CAACC,OAAD,EAAUL,KAAK,CAACW,UAAN,CAAiBR,yBAAjB,CAAV,CADH,CAApB,CAAA;;EAIA,IAAI,CAACO,WAAL,EAAkB;AAChB,IAAA,MAAM,IAAIE,KAAJ,CAAU,wDAAV,CAAN,CAAA;AACD,GAAA;;AAED,EAAA,OAAOF,WAAP,CAAA;AACD,EAVM;AA4BA,MAAMG,mBAAmB,GAAG,CAAC;EAClCC,MADkC;EAElCC,QAFkC;EAGlCV,OAHkC;AAIlCC,EAAAA,cAAc,GAAG,KAAA;AAJiB,CAAD,KAKU;EAC3CN,KAAK,CAACgB,SAAN,CAAgB,MAAM;AACpBF,IAAAA,MAAM,CAACG,KAAP,EAAA,CAAA;AACA,IAAA,OAAO,MAAM;AACXH,MAAAA,MAAM,CAACI,OAAP,EAAA,CAAA;KADF,CAAA;GAFF,EAKG,CAACJ,MAAD,CALH,CAAA,CAAA;
|
|
1
|
+
{"version":3,"file":"QueryClientProvider.mjs","sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\nimport type { ContextOptions } from './types'\n\ndeclare global {\n interface Window {\n ReactQueryClientContext?: React.Context<QueryClient | undefined>\n }\n}\n\nexport const defaultContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\nconst QueryClientSharingContext = React.createContext<boolean>(false)\n\n// If we are given a context, we will use it.\n// Otherwise, if contextSharing is on, we share the first and at least one\n// instance of the context across the window\n// to ensure that if React Query is used across\n// different bundles or microfrontends they will\n// all use the same **instance** of context, regardless\n// of module scoping.\nfunction getQueryClientContext(\n context: React.Context<QueryClient | undefined> | undefined,\n contextSharing: boolean,\n) {\n if (context) {\n return context\n }\n if (contextSharing && typeof window !== 'undefined') {\n if (!window.ReactQueryClientContext) {\n window.ReactQueryClientContext = defaultContext\n }\n\n return window.ReactQueryClientContext\n }\n\n return defaultContext\n}\n\nexport const useQueryClient = ({ context }: ContextOptions = {}) => {\n const queryClient = React.useContext(\n getQueryClientContext(context, React.useContext(QueryClientSharingContext)),\n )\n\n if (!queryClient) {\n throw new Error('No QueryClient set, use QueryClientProvider to set one')\n }\n\n return queryClient\n}\n\ntype QueryClientProviderPropsBase = {\n client: QueryClient\n children?: React.ReactNode\n}\ntype QueryClientProviderPropsWithContext = ContextOptions & {\n contextSharing?: never\n} & QueryClientProviderPropsBase\ntype QueryClientProviderPropsWithContextSharing = {\n context?: never\n contextSharing?: boolean\n} & QueryClientProviderPropsBase\n\nexport type QueryClientProviderProps =\n | QueryClientProviderPropsWithContext\n | QueryClientProviderPropsWithContextSharing\n\nexport const QueryClientProvider = ({\n client,\n children,\n context,\n contextSharing = false,\n}: QueryClientProviderProps): JSX.Element => {\n React.useEffect(() => {\n client.mount()\n return () => {\n client.unmount()\n }\n }, [client])\n\n if (process.env.NODE_ENV !== 'production' && contextSharing) {\n client\n .getLogger()\n .error(\n `The contextSharing option has been deprecated and will be removed in the next major version`,\n )\n }\n\n const Context = getQueryClientContext(context, contextSharing)\n\n return (\n <QueryClientSharingContext.Provider value={!context && contextSharing}>\n <Context.Provider value={client}>{children}</Context.Provider>\n </QueryClientSharingContext.Provider>\n )\n}\n"],"names":["defaultContext","React","createContext","undefined","QueryClientSharingContext","getQueryClientContext","context","contextSharing","window","ReactQueryClientContext","useQueryClient","queryClient","useContext","Error","QueryClientProvider","client","children","useEffect","mount","unmount","process","env","NODE_ENV","getLogger","error","Context"],"mappings":";;AAWO,MAAMA,cAAc,gBAAGC,KAAK,CAACC,aAAN,CAC5BC,SAD4B,EAAvB;AAGP,MAAMC,yBAAyB,gBAAGH,KAAK,CAACC,aAAN,CAA6B,KAA7B,CAAlC;AAGA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASG,qBAAT,CACEC,OADF,EAEEC,cAFF,EAGE;AACA,EAAA,IAAID,OAAJ,EAAa;AACX,IAAA,OAAOA,OAAP,CAAA;AACD,GAAA;;AACD,EAAA,IAAIC,cAAc,IAAI,OAAOC,MAAP,KAAkB,WAAxC,EAAqD;AACnD,IAAA,IAAI,CAACA,MAAM,CAACC,uBAAZ,EAAqC;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KAAA,CAAA,aAAA,CAAC,OAAD,CAAS,QAAT,EAAA;AAAkB,IAAA,KAAK,EAAEQ,MAAAA;GAASC,EAAAA,QAAlC,CADF,CADF,CAAA;AAKD;;;;"}
|
|
@@ -1256,9 +1256,8 @@
|
|
|
1256
1256
|
|
|
1257
1257
|
function getDefaultState$1(options) {
|
|
1258
1258
|
const data = typeof options.initialData === 'function' ? options.initialData() : options.initialData;
|
|
1259
|
-
const hasInitialData = typeof options.initialData !== 'undefined';
|
|
1260
|
-
const initialDataUpdatedAt = hasInitialData ? typeof options.initialDataUpdatedAt === 'function' ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;
|
|
1261
1259
|
const hasData = typeof data !== 'undefined';
|
|
1260
|
+
const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === 'function' ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;
|
|
1262
1261
|
return {
|
|
1263
1262
|
data,
|
|
1264
1263
|
dataUpdateCount: 0,
|
|
@@ -1866,6 +1865,10 @@
|
|
|
1866
1865
|
this.defaultOptions = config.defaultOptions || {};
|
|
1867
1866
|
this.queryDefaults = [];
|
|
1868
1867
|
this.mutationDefaults = [];
|
|
1868
|
+
|
|
1869
|
+
if (config.logger) {
|
|
1870
|
+
this.logger.error("Passing a custom logger has been deprecated and will be removed in the next major version.");
|
|
1871
|
+
}
|
|
1869
1872
|
}
|
|
1870
1873
|
|
|
1871
1874
|
mount() {
|
|
@@ -2239,6 +2242,10 @@
|
|
|
2239
2242
|
const prevQuery = this.currentQuery;
|
|
2240
2243
|
this.options = this.client.defaultQueryOptions(options);
|
|
2241
2244
|
|
|
2245
|
+
if (typeof (options == null ? void 0 : options.isDataEqual) !== 'undefined') {
|
|
2246
|
+
this.client.getLogger().error("The isDataEqual option has been deprecated and will be removed in the next major version. You can achieve the same functionality by passing a function as the structuralSharing option");
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2242
2249
|
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
2243
2250
|
this.client.getQueryCache().notify({
|
|
2244
2251
|
type: 'observerOptionsUpdated',
|
|
@@ -2451,7 +2458,7 @@
|
|
|
2451
2458
|
} // Keep previous data if needed
|
|
2452
2459
|
|
|
2453
2460
|
|
|
2454
|
-
if (options.keepPreviousData && !state.
|
|
2461
|
+
if (options.keepPreviousData && !state.dataUpdatedAt && prevQueryResult != null && prevQueryResult.isSuccess && status !== 'error') {
|
|
2455
2462
|
data = prevQueryResult.data;
|
|
2456
2463
|
dataUpdatedAt = prevQueryResult.dataUpdatedAt;
|
|
2457
2464
|
status = prevQueryResult.status;
|
|
@@ -3445,6 +3452,11 @@
|
|
|
3445
3452
|
client.unmount();
|
|
3446
3453
|
};
|
|
3447
3454
|
}, [client]);
|
|
3455
|
+
|
|
3456
|
+
if (contextSharing) {
|
|
3457
|
+
client.getLogger().error("The contextSharing option has been deprecated and will be removed in the next major version");
|
|
3458
|
+
}
|
|
3459
|
+
|
|
3448
3460
|
const Context = getQueryClientContext(context, contextSharing);
|
|
3449
3461
|
return /*#__PURE__*/React__namespace.createElement(QueryClientSharingContext.Provider, {
|
|
3450
3462
|
value: !context && contextSharing
|
|
@@ -3740,6 +3752,7 @@
|
|
|
3740
3752
|
exports.parseMutationArgs = parseMutationArgs;
|
|
3741
3753
|
exports.parseMutationFilterArgs = parseMutationFilterArgs;
|
|
3742
3754
|
exports.parseQueryArgs = parseQueryArgs;
|
|
3755
|
+
exports.replaceEqualDeep = replaceEqualDeep;
|
|
3743
3756
|
exports.useHydrate = useHydrate;
|
|
3744
3757
|
exports.useInfiniteQuery = useInfiniteQuery;
|
|
3745
3758
|
exports.useIsFetching = useIsFetching;
|