Skip to content

Commit 2c6088e

Browse files
committed
Fix getFiberName not considering displayName
1 parent ada00bf commit 2c6088e

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

packages/react-reconciler/src/ReactDebugFiberPerf.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ const getFiberLabel = (
121121

122122
const getFiberName = (fiber: Fiber): string | null => {
123123
if (fiber.tag === SimpleMemoComponent) {
124-
const innerName = getComponentName(fiber.type);
125-
return `Memo${innerName !== null ? `(${innerName})` : ''}`;
124+
return getComponentName(fiber.elementType);
126125
}
127126

128127
return getComponentName(fiber.type);

packages/react-reconciler/src/__tests__/ReactIncrementalPerf-test.internal.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,9 +573,14 @@ describe('ReactDebugFiberPerf', () => {
573573
const MemoFoo = React.memo(function Foo() {
574574
return <div />;
575575
});
576+
const MemoBar = React.memo(function Bar() {
577+
return <span />;
578+
});
579+
MemoBar.displayName = 'NamedBar';
576580
ReactNoop.render(
577581
<Parent>
578582
<MemoFoo />
583+
<MemoBar />
579584
</Parent>,
580585
);
581586
expect(Scheduler).toFlushWithoutYielding();

packages/react-reconciler/src/__tests__/__snapshots__/ReactIncrementalPerf-test.internal.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ exports[`ReactDebugFiberPerf supports memo 1`] = `
380380
"⚛ (React Tree Reconciliation: Completed Root)
381381
⚛ Parent [mount]
382382
⚛ Memo(Foo) [mount]
383+
⚛ NamedBar [mount]
383384
384385
⚛ (Committing Changes)
385386
⚛ (Committing Snapshot Effects: 0 Total)

0 commit comments

Comments
 (0)