Skip to content

Commit

Permalink
enhance: Only show devtools button when DevToolsManager is used
Browse files Browse the repository at this point in the history
  • Loading branch information
ntucker committed May 8, 2024
1 parent 0d24fee commit 30208fb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .changeset/smooth-brooms-provide.md
@@ -0,0 +1,9 @@
---
"@data-client/react": patch
---

Only show devtools button when DevToolsManager is used

Previously, one could use custom managers list and it
would still show the devtools button. This was confusing
as opening it would show no instance for Data Client.
2 changes: 1 addition & 1 deletion packages/react/src/components/CacheProvider.tsx
Expand Up @@ -78,7 +78,7 @@ Try using https://dataclient.io/docs/api/ExternalCacheProvider for server entry
>
{children}
</CacheStore>
{renderDevButton(devButton)}
{renderDevButton(devButton, managersRef.current)}
</ControllerContext.Provider>
);
}
Expand Down
10 changes: 8 additions & 2 deletions packages/react/src/components/renderDevButton.tsx
@@ -1,14 +1,20 @@
import React, { lazy } from 'react';
import { DevToolsManager, type Manager } from '@data-client/core';
import { lazy } from 'react';

import type { DevToolsPosition } from './DevToolsButton.js';
import { LegacyReact, SSR } from './LegacyReact.js';
import UniversalSuspense from './UniversalSuspense.js';

export function renderDevButton(
devButton: DevToolsPosition | null | undefined,
managers: Manager[],
) {
/* istanbul ignore else */
if (process.env.NODE_ENV !== 'production') {
if (
process.env.NODE_ENV !== 'production' &&
// only include if they have devtools integrated
managers.find(manager => manager instanceof DevToolsManager)
) {
return (
<UniversalSuspense fallback={null}>
{
Expand Down

0 comments on commit 30208fb

Please sign in to comment.