@sonic-equipment/ui 227.0.0 → 228.0.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.
@@ -1,7 +1,7 @@
1
1
  import { ReactElement, ReactNode } from 'react';
2
2
  import { QueryClient } from '@tanstack/react-query';
3
3
  export declare const globalQueryClient: QueryClient;
4
- export declare function ReactQueryContainer({ children, enableDevTools, queryClient, }: {
4
+ export declare function ReactQueryContainer({ children, enableDevTools, queryClient: _queryClient, }: {
5
5
  children: ReactNode | ((args: {
6
6
  queryClient: QueryClient;
7
7
  }) => ReactNode | ReactElement);
@@ -1,21 +1,26 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useMemo } from 'react';
3
4
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
4
5
  import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
5
6
  import { environment } from '../utils/environment.js';
6
7
  import { TIME } from '../utils/time.js';
7
8
 
8
- const globalQueryClient = new QueryClient({
9
- defaultOptions: {
10
- queries: {
11
- /* Set gcTime and staleTime to 0 to disable react query cache */
12
- gcTime: 1 * TIME.DAY,
13
- retry: false,
14
- staleTime: 1 * TIME.DAY,
9
+ function createQueryClient() {
10
+ return new QueryClient({
11
+ defaultOptions: {
12
+ queries: {
13
+ /* Set gcTime and staleTime to 0 to disable react query cache */
14
+ gcTime: 1 * TIME.DAY,
15
+ retry: false,
16
+ staleTime: 1 * TIME.DAY,
17
+ },
15
18
  },
16
- },
17
- });
18
- function ReactQueryContainer({ children, enableDevTools = environment !== 'production', queryClient = globalQueryClient, }) {
19
+ });
20
+ }
21
+ const globalQueryClient = createQueryClient();
22
+ function ReactQueryContainer({ children, enableDevTools = environment !== 'production', queryClient: _queryClient, }) {
23
+ const queryClient = useMemo(() => _queryClient || createQueryClient(), [_queryClient]);
19
24
  return (jsxs(QueryClientProvider, { client: queryClient, children: [enableDevTools && jsx(ReactQueryDevtools, { initialIsOpen: false }), children instanceof Function ? children({ queryClient }) : children] }));
20
25
  }
21
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "227.0.0",
3
+ "version": "228.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {