You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/app/react-tools/RootProvider.tsx

29 lines
966 B

import { ReactQueryDevtools } from 'react-query/devtools';
import { QueryClient, QueryClientProvider } from 'react-query';
import { UIRouterContextComponent } from '@uirouter/react-hybrid';
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>
<QueryClientProvider client={queryClient}>
<UIRouterContextComponent>
<UserProvider>{children}</UserProvider>
</UIRouterContextComponent>
{showReactQueryDevtools && <ReactQueryDevtools />}
</QueryClientProvider>
</StrictMode>
);
}