Skip to content

Commit 0face84

Browse files
committed
Exclude forwardRef and memo from stack frames
We can't patch the row. We could give these their own "built-in" stack frame since they're conceptually HoCs. However, from a debugging perspective this is not very useful meta data and quite noisy. So I'm just going to exclude them.
1 parent d48dbb8 commit 0face84

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

packages/react-reconciler/src/ReactFiberComponentStack.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
FunctionComponent,
1818
IndeterminateComponent,
1919
ForwardRef,
20-
MemoComponent,
2120
SimpleMemoComponent,
2221
Block,
2322
ClassComponent,
@@ -50,8 +49,6 @@ function describeFiber(fiber: Fiber): string {
5049
return describeFunctionComponentFrame(fiber.type, source, owner);
5150
case ForwardRef:
5251
return describeFunctionComponentFrame(fiber.type.render, source, owner);
53-
case MemoComponent:
54-
return describeFunctionComponentFrame(fiber.type.type, source, owner);
5552
case Block:
5653
return describeFunctionComponentFrame(fiber.type._render, source, owner);
5754
case ClassComponent:

packages/react-reconciler/src/__tests__/ReactMemo-test.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,12 +392,20 @@ describe('memo', () => {
392392
Outer.defaultProps = {outer: 0};
393393

394394
// No warning expected because defaultProps satisfy both.
395-
ReactNoop.render(<Outer />);
395+
ReactNoop.render(
396+
<div>
397+
<Outer />
398+
</div>,
399+
);
396400
expect(Scheduler).toFlushWithoutYielding();
397401

398402
// Mount
399403
expect(() => {
400-
ReactNoop.render(<Outer inner="2" middle="3" outer="4" />);
404+
ReactNoop.render(
405+
<div>
406+
<Outer inner="2" middle="3" outer="4" />
407+
</div>,
408+
);
401409
expect(Scheduler).toFlushWithoutYielding();
402410
}).toErrorDev([
403411
'Invalid prop `outer` of type `string` supplied to `Inner`, expected `number`.',
@@ -408,7 +416,9 @@ describe('memo', () => {
408416
// Update
409417
expect(() => {
410418
ReactNoop.render(
411-
<Outer inner={false} middle={false} outer={false} />,
419+
<div>
420+
<Outer inner={false} middle={false} outer={false} />
421+
</div>,
412422
);
413423
expect(Scheduler).toFlushWithoutYielding();
414424
}).toErrorDev([

packages/shared/ReactComponentStackFrame.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export function describeUnknownElementTypeFrameInDEV(
121121
case REACT_FORWARD_REF_TYPE:
122122
return describeFunctionComponentFrame(type.render, source, ownerFn);
123123
case REACT_MEMO_TYPE:
124-
return describeFunctionComponentFrame(type.type, source, ownerFn);
124+
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
125125
case REACT_BLOCK_TYPE:
126126
return describeFunctionComponentFrame(type._render, source, ownerFn);
127127
case REACT_LAZY_TYPE: {

0 commit comments

Comments
 (0)