From acac580191aeb5f59081b166282ba1a5de291080 Mon Sep 17 00:00:00 2001 From: Karan Janthe <86996507+KMJ-007@users.noreply.github.com> Date: Wed, 23 Oct 2024 20:09:03 +0530 Subject: [PATCH] fix: should not render tanstack router devtool in production (#155) --- src/routes/__root.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/routes/__root.tsx b/src/routes/__root.tsx index b4a79a0..16dc731 100644 --- a/src/routes/__root.tsx +++ b/src/routes/__root.tsx @@ -1,5 +1,14 @@ import { createRootRoute, Outlet } from '@tanstack/react-router'; -import { TanStackRouterDevtools } from '@tanstack/router-devtools'; + +const TanStackRouterDevtools = + process.env.NODE_ENV === 'production' + ? () => null // Render nothing in production + : React.lazy(() => + // Lazy load in development + import('@tanstack/router-devtools').then((res) => ({ + default: res.TanStackRouterDevtools + })), + ) export const Route = createRootRoute({ component: () => (