router icon indicating copy to clipboard operation
router copied to clipboard

React Location dev tools isn't hidden in production

Open mhesham32 opened this issue 2 years ago • 5 comments

Describe the bug

I have dev tools from React Query and React Location and when I deployed the app to production only react query dev tools was hidden but react location dev tools wasn't

Your Example Website or App

https://heartfelt-lokum-be0567.netlify.app/

Steps to Reproduce the Bug or Issue

put the tools component under the Router component

<ReactLocationDevtools position="top-right" />

Expected behavior

I'm expecting it to be not included in the prod build same as React Query tools

Screenshots or Videos

image image

Platform

  • OS: Windows
  • Browser:Chrome
  • Version: 107

Additional context

No response

mhesham32 avatar Nov 10 '22 17:11 mhesham32

https://tanstack.com/router/v1/docs/devtools#only-importing-and-using-devtools-in-production

tannerlinsley avatar Nov 10 '22 18:11 tannerlinsley

thanks, I think I will use that. but shouldn't it be hidden in production even if it was imported at the top

mhesham32 avatar Nov 10 '22 19:11 mhesham32

also, I'm using these two packages

import { Router, ReactLocation } from '@tanstack/react-location';
import { ReactLocationDevtools as RLD } from '@tanstack/react-location-devtools';

the one mentioned in the link is @tanstack/react-router-devtools which one should I use?

mhesham32 avatar Nov 10 '22 19:11 mhesham32

You can accomplish the same pattern with the react-location imports. Should work fine!

tannerlinsley avatar Nov 10 '22 21:11 tannerlinsley

thanks, I got an error doing that so I ended up importing it like this

const ReactLocationDevtools =
  process.env.NODE_ENV === 'production'
    ? () => null // Render nothing in production
    : lazy(() =>
        import('@tanstack/react-location-devtools').then((m) => ({
          default: m.ReactLocationDevtools,
        }))
      );

mhesham32 avatar Nov 11 '22 16:11 mhesham32

FWIW, it looks like the name has changed from ReactLocationDevtools to TanStackRouterDevtools. Thanks for the tip about the default export, @mhesham32.

IanVS avatar Nov 15 '22 17:11 IanVS