Skip to content

Commit 18bf7bf

Browse files
authored
[DevTools] Remove displayName from inspected data (#30841)
This just clarifies that this is actually unused in the front end. We use the name from the original instance as the canonical name.
1 parent a19a8ab commit 18bf7bf

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

packages/react-devtools-shared/src/backend/fiber/renderer.js

+3-10
Original file line numberDiff line numberDiff line change
@@ -4212,7 +4212,6 @@ export function attach(
42124212

42134213
key: key != null ? key : null,
42144214

4215-
displayName: getDisplayNameForFiber(fiber),
42164215
type: elementType,
42174216

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

4255-
const env = componentInfo.env;
4256-
let displayName = componentInfo.name || '';
4257-
if (typeof env === 'string') {
4258-
// We model environment as an HoC name for now.
4259-
displayName = env + '(' + displayName + ')';
4260-
}
4261-
42624254
const owners: null | Array<SerializedElement> =
42634255
getOwnersListFromInstance(virtualInstance);
42644256

@@ -4311,7 +4303,6 @@ export function attach(
43114303

43124304
key: key,
43134305

4314-
displayName: displayName,
43154306
type: ElementTypeVirtual,
43164307

43174308
// Inspectable properties.
@@ -4675,10 +4666,12 @@ export function attach(
46754666
return;
46764667
}
46774668

4669+
const displayName = getDisplayNameForElementID(id);
4670+
46784671
const supportsGroup = typeof console.groupCollapsed === 'function';
46794672
if (supportsGroup) {
46804673
console.groupCollapsed(
4681-
`[Click to expand] %c<${result.displayName || 'Component'} />`,
4674+
`[Click to expand] %c<${displayName || 'Component'} />`,
46824675
// --dom-tag-name-color is the CSS variable Chrome styles HTML elements with in the console.
46834676
'color: var(--dom-tag-name-color); font-weight: normal;',
46844677
);

packages/react-devtools-shared/src/backend/legacy/renderer.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ export function attach(
775775
return null;
776776
}
777777

778-
const {displayName, key} = getData(internalInstance);
778+
const {key} = getData(internalInstance);
779779
const type = getElementType(internalInstance);
780780

781781
let context = null;
@@ -842,8 +842,6 @@ export function attach(
842842
// Only legacy context exists in legacy versions.
843843
hasLegacyContext: true,
844844

845-
displayName: displayName,
846-
847845
type: type,
848846

849847
key: key != null ? key : null,
@@ -876,10 +874,12 @@ export function attach(
876874
return;
877875
}
878876

877+
const displayName = getDisplayNameForElementID(id);
878+
879879
const supportsGroup = typeof console.groupCollapsed === 'function';
880880
if (supportsGroup) {
881881
console.groupCollapsed(
882-
`[Click to expand] %c<${result.displayName || 'Component'} />`,
882+
`[Click to expand] %c<${displayName || 'Component'} />`,
883883
// --dom-tag-name-color is the CSS variable Chrome styles HTML elements with in the console.
884884
'color: var(--dom-tag-name-color); font-weight: normal;',
885885
);

packages/react-devtools-shared/src/backend/types.js

-2
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ export type OwnersList = {
239239
export type InspectedElement = {
240240
id: number,
241241

242-
displayName: string | null,
243-
244242
// Does the current renderer support editable hooks and function props?
245243
canEditHooks: boolean,
246244
canEditFunctionProps: boolean,

0 commit comments

Comments
 (0)