Skip to content

Commit

Permalink
[DevTools] Remove displayName from inspected data (#30841)
Browse files Browse the repository at this point in the history
This just clarifies that this is actually unused in the front end. We
use the name from the original instance as the canonical name.
  • Loading branch information
sebmarkbage authored Aug 29, 2024
1 parent a19a8ab commit 18bf7bf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
13 changes: 3 additions & 10 deletions packages/react-devtools-shared/src/backend/fiber/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4212,7 +4212,6 @@ export function attach(

key: key != null ? key : null,

displayName: getDisplayNameForFiber(fiber),
type: elementType,

// Inspectable properties.
Expand Down Expand Up @@ -4252,13 +4251,6 @@ export function attach(
typeof componentInfo.key === 'string' ? componentInfo.key : null;
const props = null; // TODO: Track props on ReactComponentInfo;

const env = componentInfo.env;
let displayName = componentInfo.name || '';
if (typeof env === 'string') {
// We model environment as an HoC name for now.
displayName = env + '(' + displayName + ')';
}

const owners: null | Array<SerializedElement> =
getOwnersListFromInstance(virtualInstance);

Expand Down Expand Up @@ -4311,7 +4303,6 @@ export function attach(

key: key,

displayName: displayName,
type: ElementTypeVirtual,

// Inspectable properties.
Expand Down Expand Up @@ -4675,10 +4666,12 @@ export function attach(
return;
}

const displayName = getDisplayNameForElementID(id);

const supportsGroup = typeof console.groupCollapsed === 'function';
if (supportsGroup) {
console.groupCollapsed(
`[Click to expand] %c<${result.displayName || 'Component'} />`,
`[Click to expand] %c<${displayName || 'Component'} />`,
// --dom-tag-name-color is the CSS variable Chrome styles HTML elements with in the console.
'color: var(--dom-tag-name-color); font-weight: normal;',
);
Expand Down
8 changes: 4 additions & 4 deletions packages/react-devtools-shared/src/backend/legacy/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ export function attach(
return null;
}

const {displayName, key} = getData(internalInstance);
const {key} = getData(internalInstance);
const type = getElementType(internalInstance);

let context = null;
Expand Down Expand Up @@ -842,8 +842,6 @@ export function attach(
// Only legacy context exists in legacy versions.
hasLegacyContext: true,

displayName: displayName,

type: type,

key: key != null ? key : null,
Expand Down Expand Up @@ -876,10 +874,12 @@ export function attach(
return;
}

const displayName = getDisplayNameForElementID(id);

const supportsGroup = typeof console.groupCollapsed === 'function';
if (supportsGroup) {
console.groupCollapsed(
`[Click to expand] %c<${result.displayName || 'Component'} />`,
`[Click to expand] %c<${displayName || 'Component'} />`,
// --dom-tag-name-color is the CSS variable Chrome styles HTML elements with in the console.
'color: var(--dom-tag-name-color); font-weight: normal;',
);
Expand Down
2 changes: 0 additions & 2 deletions packages/react-devtools-shared/src/backend/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ export type OwnersList = {
export type InspectedElement = {
id: number,

displayName: string | null,

// Does the current renderer support editable hooks and function props?
canEditHooks: boolean,
canEditFunctionProps: boolean,
Expand Down

0 comments on commit 18bf7bf

Please sign in to comment.