Skip to content

Commit

Permalink
Merge pull request #210 from openscript-ch/205-tanstack-router-devtoo…
Browse files Browse the repository at this point in the history
…ls-displayed-in-production

chore: react router devtools only in production
  • Loading branch information
openscript authored Dec 20, 2024
2 parents c93f72c + 17e7498 commit 4f18364
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,
}))
);

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" />
</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 4f18364

Please sign in to comment.