Skip to content

Commit

Permalink
Exclude forwardRef and memo from stack frames
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sebmarkbage committed Apr 9, 2020
1 parent d48dbb8 commit 0face84
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 0 additions & 3 deletions packages/react-reconciler/src/ReactFiberComponentStack.js
Expand Up @@ -17,7 +17,6 @@ import {
FunctionComponent,
IndeterminateComponent,
ForwardRef,
MemoComponent,
SimpleMemoComponent,
Block,
ClassComponent,
Expand Down Expand Up @@ -50,8 +49,6 @@ function describeFiber(fiber: Fiber): string {
return describeFunctionComponentFrame(fiber.type, source, owner);
case ForwardRef:
return describeFunctionComponentFrame(fiber.type.render, source, owner);
case MemoComponent:
return describeFunctionComponentFrame(fiber.type.type, source, owner);
case Block:
return describeFunctionComponentFrame(fiber.type._render, source, owner);
case ClassComponent:
Expand Down
16 changes: 13 additions & 3 deletions packages/react-reconciler/src/__tests__/ReactMemo-test.js
Expand Up @@ -392,12 +392,20 @@ describe('memo', () => {
Outer.defaultProps = {outer: 0};

// No warning expected because defaultProps satisfy both.
ReactNoop.render(<Outer />);
ReactNoop.render(
<div>
<Outer />
</div>,
);
expect(Scheduler).toFlushWithoutYielding();

// Mount
expect(() => {
ReactNoop.render(<Outer inner="2" middle="3" outer="4" />);
ReactNoop.render(
<div>
<Outer inner="2" middle="3" outer="4" />
</div>,
);
expect(Scheduler).toFlushWithoutYielding();
}).toErrorDev([
'Invalid prop `outer` of type `string` supplied to `Inner`, expected `number`.',
Expand All @@ -408,7 +416,9 @@ describe('memo', () => {
// Update
expect(() => {
ReactNoop.render(
<Outer inner={false} middle={false} outer={false} />,
<div>
<Outer inner={false} middle={false} outer={false} />
</div>,
);
expect(Scheduler).toFlushWithoutYielding();
}).toErrorDev([
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/ReactComponentStackFrame.js
Expand Up @@ -121,7 +121,7 @@ export function describeUnknownElementTypeFrameInDEV(
case REACT_FORWARD_REF_TYPE:
return describeFunctionComponentFrame(type.render, source, ownerFn);
case REACT_MEMO_TYPE:
return describeFunctionComponentFrame(type.type, source, ownerFn);
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
case REACT_BLOCK_TYPE:
return describeFunctionComponentFrame(type._render, source, ownerFn);
case REACT_LAZY_TYPE: {
Expand Down

0 comments on commit 0face84

Please sign in to comment.