2021-12-15 09:43:49 +00:00
|
|
|
import { ReactQueryDevtools } from 'react-query/devtools';
|
|
|
|
import { QueryClient, QueryClientProvider } from 'react-query';
|
2021-11-16 16:33:51 +00:00
|
|
|
import { UIRouterContextComponent } from '@uirouter/react-hybrid';
|
2021-12-15 09:43:49 +00:00
|
|
|
import { PropsWithChildren, StrictMode, useState, useEffect } from 'react';
|
2021-11-16 16:33:51 +00:00
|
|
|
|
2021-12-14 19:14:53 +00:00
|
|
|
import { UserProvider } from '@/portainer/hooks/useUser';
|
|
|
|
|
2021-12-15 09:43:49 +00:00
|
|
|
const queryClient = new QueryClient();
|
|
|
|
|
2021-11-16 16:33:51 +00:00
|
|
|
export function RootProvider({ children }: PropsWithChildren<unknown>) {
|
2021-12-15 09:43:49 +00:00
|
|
|
const [showReactQueryDevtools, setShowReactQueryDevtools] = useState(false);
|
|
|
|
useEffect(() => {
|
|
|
|
if (process.env.SHOW_REACT_QUERY_DEV_TOOLS === 'true') {
|
|
|
|
setShowReactQueryDevtools(true);
|
|
|
|
}
|
|
|
|
}, []);
|
|
|
|
|
2021-11-16 16:33:51 +00:00
|
|
|
return (
|
|
|
|
<StrictMode>
|
2021-12-15 09:43:49 +00:00
|
|
|
<QueryClientProvider client={queryClient}>
|
|
|
|
<UIRouterContextComponent>
|
|
|
|
<UserProvider>{children}</UserProvider>
|
|
|
|
</UIRouterContextComponent>
|
|
|
|
{showReactQueryDevtools && <ReactQueryDevtools />}
|
|
|
|
</QueryClientProvider>
|
2021-11-16 16:33:51 +00:00
|
|
|
</StrictMode>
|
|
|
|
);
|
|
|
|
}
|