devtools icon indicating copy to clipboard operation
devtools copied to clipboard

Add enable props

Open tyankatsu0105 opened this issue 5 years ago • 4 comments

Hi. I love this devtools. Thanks for all contributors!

Currently, this devtools UI are included application ifNODE_ENV is NOT production. But, I think people who want to create an application as experimental wants to enable devtools UI in production build. I'm one of them. https://sandbox-redux-toolkit-create-entity-adapter.vercel.app/ (In this case, I wroteimport * as ReactHookFormDevTool from '@hookform/devtools/dist/index.cjs.development.js'; https://github.com/tyankatsu0105/sandbox-redux-toolkit-create-entity-adapter/blob/15e845c47090a03e5baf0d4ab8306ae651ea19ce/apps/client/components/create/add-one/add-one.container.tsx#L5)

So, I propose props enable: boolean to <DevTool /> Like this:

import * as ReactHookFormDevTool from "@hookform/devtools/dist/index.cjs.development.js";

export const Component = () => (
  <ReactHookFormDevTool.DevTool control={control} enable />
);
// or
export const Component = () => (
  <ReactHookFormDevTool.DevTool
    control={control}
    enable={NODE_ENV === "production"}
  />
);

tyankatsu0105 avatar Oct 10 '20 15:10 tyankatsu0105

To figure out the build at the run time is a bit trigger, maybe we should produce a build which also has the Devtool even at prod build.

bluebill1049 avatar Oct 10 '20 22:10 bluebill1049

maybe we should produce a build which also has the Devtool even at prod build.

Sounds good. I checked this issue. https://github.com/react-hook-form/devtools/issues/18 Probably to build Devtool even at production build is cause issue about performance. Has that issue already solve?

tyankatsu0105 avatar Oct 11 '20 01:10 tyankatsu0105

That issue is already resolved.

bluebill1049 avatar Oct 11 '20 01:10 bluebill1049

I'd like to try this issue. So.. what can I do?

tyankatsu0105 avatar Dec 15 '20 14:12 tyankatsu0105