Skip to content

Commit 4a9a836

Browse files
authored
feat: Added displayName to React contexts (#2512)
Added displayName to React contexts so that they can be identified in React dev tools. Part of DH-19529 ### Testing - Run DH web locally via `npm start` - Open Components tab from React dev tools - Verify that context providers now have names in the component tree
1 parent eca54ca commit 4a9a836

19 files changed

Lines changed: 20 additions & 0 deletions

packages/app-utils/src/components/ConnectionContext.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ import { createContext } from 'react';
22
import type { dh } from '@deephaven/jsapi-types';
33

44
export const ConnectionContext = createContext<dh.IdeConnection | null>(null);
5+
ConnectionContext.displayName = 'ConnectionContext';
56

67
export default ConnectionContext;

packages/app-utils/src/components/FontBootstrap.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import '@fontsource/fira-sans/700.css';
1212
import '@fontsource/fira-sans/700-italic.css';
1313

1414
export const FontsLoadedContext = createContext<boolean>(false);
15+
FontsLoadedContext.displayName = 'FontsLoadedContext';
1516

1617
export type FontBootstrapProps = {
1718
/**

packages/app-utils/src/components/ServerConfigBootstrap.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { getErrorMessage } from '@deephaven/utils';
66
export const ServerConfigContext = createContext<Map<string, string> | null>(
77
null
88
);
9+
ServerConfigContext.displayName = 'ServerConfigContext';
910

1011
export type ServerConfigBootstrapProps = {
1112
/**

packages/auth-plugins/src/UserContexts.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ export const UserOverrideContext = createContext<UserOverride>({});
99

1010
export const UserPermissionsOverrideContext =
1111
createContext<UserPermissionsOverride>({});
12+
UserPermissionsOverrideContext.displayName = 'UserPermissionsOverrideContext';
1213

1314
export const UserContext = createContext<User | null>(null);
15+
UserContext.displayName = 'UserContext';

packages/chart/src/ChartThemeProvider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export type ChartThemeContextValue = ChartTheme;
77
export const ChartThemeContext = createContext<ChartThemeContextValue | null>(
88
null
99
);
10+
ChartThemeContext.displayName = 'ChartThemeContext';
1011

1112
export interface ChartThemeProviderProps {
1213
children: ReactNode;

packages/components/src/XComponentMap.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const XComponentMapContext = React.createContext(
1313
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1414
new Map<React.ComponentType<any>, React.ComponentType<any>>()
1515
);
16+
XComponentMapContext.displayName = 'XComponentMapContext';
1617

1718
export const XComponentMapProvider = XComponentMapContext.Provider;
1819

packages/components/src/theme/ThemeProvider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface ThemeContextValue {
2828
const log = Log.module('ThemeProvider');
2929

3030
export const ThemeContext = createContext<ThemeContextValue | null>(null);
31+
ThemeContext.displayName = 'ThemeContext';
3132

3233
export interface ThemeProviderProps {
3334
/*

packages/dashboard/src/layout/LayoutManagerContext.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ import type GoldenLayout from '@deephaven/golden-layout';
33

44
export const LayoutManagerContext: React.Context<GoldenLayout | undefined> =
55
React.createContext<GoldenLayout | undefined>(undefined);
6+
LayoutManagerContext.displayName = 'LayoutManagerContext';
67

78
export default LayoutManagerContext;

packages/dashboard/src/useDashboardId.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createContext, useContext } from 'react';
22

33
export const DashboardIdContext = createContext<string | null>(null);
4+
DashboardIdContext.displayName = 'DashboardIdContext';
45

56
export function useDashboardId(): string {
67
const dashboardId = useContext(DashboardIdContext);

packages/dashboard/src/useFiber.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ const FiberContext = /* @__PURE__ */ wrapContext(
8585
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
8686
/* @__PURE__ */ React.createContext<Fiber>(null!)
8787
);
88+
FiberContext.displayName = 'FiberContext';
8889

8990
/**
9091
* A react-internal {@link Fiber} provider. This component binds React children to the React Fiber tree. Call its-fine hooks within this.

0 commit comments

Comments
 (0)