mirror of
https://github.com/portainer/portainer.git
synced 2025-07-25 08:19:40 +02:00
add switch for react query devtools based on .env (#6280)
This commit is contained in:
parent
f99329eb7e
commit
ac9ca7d5e3
4 changed files with 128 additions and 13 deletions
|
@ -1,14 +1,28 @@
|
|||
import { ReactQueryDevtools } from 'react-query/devtools';
|
||||
import { QueryClient, QueryClientProvider } from 'react-query';
|
||||
import { UIRouterContextComponent } from '@uirouter/react-hybrid';
|
||||
import { PropsWithChildren, StrictMode } from 'react';
|
||||
import { PropsWithChildren, StrictMode, useState, useEffect } from 'react';
|
||||
|
||||
import { UserProvider } from '@/portainer/hooks/useUser';
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
export function RootProvider({ children }: PropsWithChildren<unknown>) {
|
||||
const [showReactQueryDevtools, setShowReactQueryDevtools] = useState(false);
|
||||
useEffect(() => {
|
||||
if (process.env.SHOW_REACT_QUERY_DEV_TOOLS === 'true') {
|
||||
setShowReactQueryDevtools(true);
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<StrictMode>
|
||||
<UIRouterContextComponent>
|
||||
<UserProvider>{children}</UserProvider>
|
||||
</UIRouterContextComponent>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<UIRouterContextComponent>
|
||||
<UserProvider>{children}</UserProvider>
|
||||
</UIRouterContextComponent>
|
||||
{showReactQueryDevtools && <ReactQueryDevtools />}
|
||||
</QueryClientProvider>
|
||||
</StrictMode>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue