mirror of
https://github.com/coder/coder.git
synced 2026-09-21 20:51:01 +08:00
added react query dev tools (#11293)
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
"@mui/material": "5.14.0",
|
||||
"@mui/system": "5.14.0",
|
||||
"@mui/utils": "5.14.11",
|
||||
"@tanstack/react-query-devtools": "4.35.3",
|
||||
"@vitejs/plugin-react": "4.1.0",
|
||||
"ansi-to-html": "0.7.2",
|
||||
"axios": "1.6.0",
|
||||
|
||||
Generated
+48
@@ -51,6 +51,9 @@ dependencies:
|
||||
'@mui/utils':
|
||||
specifier: 5.14.11
|
||||
version: 5.14.11(@types/react@18.2.6)(react@18.2.0)
|
||||
'@tanstack/react-query-devtools':
|
||||
specifier: 4.35.3
|
||||
version: 4.35.3(@tanstack/react-query@4.35.3)(react-dom@18.2.0)(react@18.2.0)
|
||||
'@vitejs/plugin-react':
|
||||
specifier: 4.1.0
|
||||
version: 4.1.0(vite@4.5.1)
|
||||
@@ -5156,10 +5159,32 @@ packages:
|
||||
jsonc-parser: 3.2.0
|
||||
dev: true
|
||||
|
||||
/@tanstack/match-sorter-utils@8.8.4:
|
||||
resolution: {integrity: sha512-rKH8LjZiszWEvmi01NR72QWZ8m4xmXre0OOwlRGnjU01Eqz/QnN+cqpty2PJ0efHblq09+KilvyR7lsbzmXVEw==}
|
||||
engines: {node: '>=12'}
|
||||
dependencies:
|
||||
remove-accents: 0.4.2
|
||||
dev: false
|
||||
|
||||
/@tanstack/query-core@4.35.3:
|
||||
resolution: {integrity: sha512-PS+WEjd9wzKTyNjjQymvcOe1yg8f3wYc6mD+vb6CKyZAKvu4sIJwryfqfBULITKCla7P9C4l5e9RXePHvZOZeQ==}
|
||||
dev: false
|
||||
|
||||
/@tanstack/react-query-devtools@4.35.3(@tanstack/react-query@4.35.3)(react-dom@18.2.0)(react@18.2.0):
|
||||
resolution: {integrity: sha512-UvLT7qPzCuCZ3NfjwsOqDUVN84JvSOuW6ukrjZmSqgjPqVxD6ra/HUp1CEOatQY2TRvKCp8y1lTVu+trXM30fg==}
|
||||
peerDependencies:
|
||||
'@tanstack/react-query': ^4.35.3
|
||||
react: ^16.8.0 || ^17.0.0 || ^18.0.0
|
||||
react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0
|
||||
dependencies:
|
||||
'@tanstack/match-sorter-utils': 8.8.4
|
||||
'@tanstack/react-query': 4.35.3(react-dom@18.2.0)(react@18.2.0)
|
||||
react: 18.2.0
|
||||
react-dom: 18.2.0(react@18.2.0)
|
||||
superjson: 1.13.3
|
||||
use-sync-external-store: 1.2.0(react@18.2.0)
|
||||
dev: false
|
||||
|
||||
/@tanstack/react-query@4.35.3(react-dom@18.2.0)(react@18.2.0):
|
||||
resolution: {integrity: sha512-UgTPioip/rGG3EQilXfA2j4BJkhEQsR+KAbF+KIuvQ7j4MkgnTCJF01SfRpIRNtQTlEfz/+IL7+jP8WA8bFbsw==}
|
||||
peerDependencies:
|
||||
@@ -7084,6 +7109,13 @@ packages:
|
||||
engines: {node: '>= 0.6'}
|
||||
dev: true
|
||||
|
||||
/copy-anything@3.0.5:
|
||||
resolution: {integrity: sha512-yCEafptTtb4bk7GLEQoM8KVJpxAfdBJYaXyzQEgQQQgYrZiDp8SJmGKlYza6CYjEDNstAdNdKA3UuoULlEbS6w==}
|
||||
engines: {node: '>=12.13'}
|
||||
dependencies:
|
||||
is-what: 4.1.16
|
||||
dev: false
|
||||
|
||||
/copy-to-clipboard@3.3.3:
|
||||
resolution: {integrity: sha512-2KV8NhB5JqC3ky0r9PMCAZKbUHSwtEo4CwCs0KXgruG43gX5PMqDEBbVU4OUzw2MuAWUfsuFmWvEKG5QRfSnJA==}
|
||||
dependencies:
|
||||
@@ -9357,6 +9389,11 @@ packages:
|
||||
get-intrinsic: 1.2.2
|
||||
dev: true
|
||||
|
||||
/is-what@4.1.16:
|
||||
resolution: {integrity: sha512-ZhMwEosbFJkA0YhFnNDgTM4ZxDRsS6HqTo7qsZM08fehyRYIYa0yHu5R6mgo1n/8MgaPBXiPimPD77baVFYg+A==}
|
||||
engines: {node: '>=12.13'}
|
||||
dev: false
|
||||
|
||||
/is-wsl@2.2.0:
|
||||
resolution: {integrity: sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==}
|
||||
engines: {node: '>=8'}
|
||||
@@ -12650,6 +12687,10 @@ packages:
|
||||
unified: 11.0.4
|
||||
dev: false
|
||||
|
||||
/remove-accents@0.4.2:
|
||||
resolution: {integrity: sha512-7pXIJqJOq5tFgG1A2Zxti3Ht8jJF337m4sowbuHsW30ZnkQFnDzy9qBNhgzX8ZLW4+UBcXiiR7SwR6pokHsxiA==}
|
||||
dev: false
|
||||
|
||||
/require-directory@2.1.1:
|
||||
resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@@ -13323,6 +13364,13 @@ packages:
|
||||
resolution: {integrity: sha512-E87pIogpwUsUwXw7dNyU4QDjdgVMy52m+XEOPEKUn161cCzWjjhPSQhByfd1CcNvrOLnXQ6OnnZDwnJrz/Z4YQ==}
|
||||
dev: false
|
||||
|
||||
/superjson@1.13.3:
|
||||
resolution: {integrity: sha512-mJiVjfd2vokfDxsQPOwJ/PtanO87LhpYY88ubI5dUB1Ab58Txbyje3+jpm+/83R/fevaq/107NNhtYBLuoTrFg==}
|
||||
engines: {node: '>=10'}
|
||||
dependencies:
|
||||
copy-anything: 3.0.5
|
||||
dev: false
|
||||
|
||||
/supports-color@5.5.0:
|
||||
resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
+18
-1
@@ -1,5 +1,5 @@
|
||||
import { QueryClient, QueryClientProvider } from "react-query";
|
||||
import type { FC, ReactNode } from "react";
|
||||
import { type FC, type ReactNode, useEffect, useState } from "react";
|
||||
import { HelmetProvider } from "react-helmet-async";
|
||||
import { AppRouter } from "./AppRouter";
|
||||
import { ThemeProvider } from "./contexts/ThemeProvider";
|
||||
@@ -7,6 +7,7 @@ import { AuthProvider } from "./contexts/AuthProvider/AuthProvider";
|
||||
import { ErrorBoundary } from "./components/ErrorBoundary/ErrorBoundary";
|
||||
import { GlobalSnackbar } from "./components/GlobalSnackbar/GlobalSnackbar";
|
||||
import "./theme/globalFonts";
|
||||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
||||
|
||||
const defaultQueryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
@@ -22,10 +23,25 @@ interface AppProvidersProps {
|
||||
queryClient?: QueryClient;
|
||||
}
|
||||
|
||||
// extending the global window interface so we can conditionally
|
||||
// show our react query devtools
|
||||
declare global {
|
||||
interface Window {
|
||||
toggleDevtools: () => void;
|
||||
}
|
||||
}
|
||||
|
||||
export const AppProviders: FC<AppProvidersProps> = ({
|
||||
children,
|
||||
queryClient = defaultQueryClient,
|
||||
}) => {
|
||||
// https://tanstack.com/query/v4/docs/react/devtools
|
||||
const [showDevtools, setShowDevtools] = useState(false);
|
||||
useEffect(() => {
|
||||
window.toggleDevtools = () => setShowDevtools((old) => !old);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- no dependencies needed here
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<HelmetProvider>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
@@ -35,6 +51,7 @@ export const AppProviders: FC<AppProvidersProps> = ({
|
||||
<GlobalSnackbar />
|
||||
</ThemeProvider>
|
||||
</AuthProvider>
|
||||
{showDevtools && <ReactQueryDevtools initialIsOpen={showDevtools} />}
|
||||
</QueryClientProvider>
|
||||
</HelmetProvider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user