Skip to content

Commit

Permalink
chore: react router devtools only in production
Browse files Browse the repository at this point in the history
  • Loading branch information
openscript committed Dec 18, 2024
1 parent 41e0afe commit 17e7498
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 10 additions & 1 deletion apps/frontend/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StrictMode } from "react";
import React, { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import "@quassel/ui/style.css";
import { ThemeProvider } from "@quassel/ui";
Expand All @@ -8,6 +8,14 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

const queryClient = new QueryClient();
const router = createRouter({ routeTree, context: { queryClient }, defaultPreload: "intent", defaultPreloadStaleTime: 0 });
const TanStackRouterDevtools =
process.env.NODE_ENV === "production"
? () => null
: React.lazy(() =>
import("@tanstack/router-devtools").then((res) => ({
default: res.TanStackRouterDevtools,
}))
);

Check warning on line 18 in apps/frontend/src/main.tsx

View check run for this annotation

Codecov / codecov/patch

apps/frontend/src/main.tsx#L11-L18

Added lines #L11 - L18 were not covered by tests

declare module "@tanstack/react-router" {
interface Register {
Expand All @@ -20,6 +28,7 @@ createRoot(document.getElementById("root")!).render(
<QueryClientProvider client={queryClient}>
<ThemeProvider>
<RouterProvider router={router} />
<TanStackRouterDevtools router={router} position="bottom-right" />

Check warning on line 31 in apps/frontend/src/main.tsx

View check run for this annotation

Codecov / codecov/patch

apps/frontend/src/main.tsx#L31

Added line #L31 was not covered by tests
</ThemeProvider>
</QueryClientProvider>
</StrictMode>
Expand Down
2 changes: 0 additions & 2 deletions apps/frontend/src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
Divider,
} from "@quassel/ui";
import { createRootRouteWithContext, Link, Outlet, useNavigate } from "@tanstack/react-router";
import { TanStackRouterDevtools } from "@tanstack/router-devtools";
import { version } from "../../package.json";
import { $session } from "../stores/session";
import { useStore } from "@nanostores/react";
Expand Down Expand Up @@ -96,7 +95,6 @@ function Root() {
</AppShell.Main>
<AppShell.Footer>Version {version}</AppShell.Footer>
</AppShell>
<TanStackRouterDevtools position="top-left" />
</>
);
}
Expand Down

0 comments on commit 17e7498

Please sign in to comment.