Exclude forwardRef and memo from stack frames (#18559)

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.
This commit is contained in:
Sebastian Markbåge 2020-04-09 11:42:22 -07:00 committed by GitHub
parent 26fc16484e
commit cbab25bb51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 7 deletions

View File

@ -17,7 +17,6 @@ import {
FunctionComponent, FunctionComponent,
IndeterminateComponent, IndeterminateComponent,
ForwardRef, ForwardRef,
MemoComponent,
SimpleMemoComponent, SimpleMemoComponent,
Block, Block,
ClassComponent, ClassComponent,
@ -50,8 +49,6 @@ function describeFiber(fiber: Fiber): string {
return describeFunctionComponentFrame(fiber.type, source, owner); return describeFunctionComponentFrame(fiber.type, source, owner);
case ForwardRef: case ForwardRef:
return describeFunctionComponentFrame(fiber.type.render, source, owner); return describeFunctionComponentFrame(fiber.type.render, source, owner);
case MemoComponent:
return describeFunctionComponentFrame(fiber.type.type, source, owner);
case Block: case Block:
return describeFunctionComponentFrame(fiber.type._render, source, owner); return describeFunctionComponentFrame(fiber.type._render, source, owner);
case ClassComponent: case ClassComponent:

View File

@ -392,12 +392,20 @@ describe('memo', () => {
Outer.defaultProps = {outer: 0}; Outer.defaultProps = {outer: 0};
// No warning expected because defaultProps satisfy both. // No warning expected because defaultProps satisfy both.
ReactNoop.render(<Outer />); ReactNoop.render(
<div>
<Outer />
</div>,
);
expect(Scheduler).toFlushWithoutYielding(); expect(Scheduler).toFlushWithoutYielding();
// Mount // Mount
expect(() => { expect(() => {
ReactNoop.render(<Outer inner="2" middle="3" outer="4" />); ReactNoop.render(
<div>
<Outer inner="2" middle="3" outer="4" />
</div>,
);
expect(Scheduler).toFlushWithoutYielding(); expect(Scheduler).toFlushWithoutYielding();
}).toErrorDev([ }).toErrorDev([
'Invalid prop `outer` of type `string` supplied to `Inner`, expected `number`.', 'Invalid prop `outer` of type `string` supplied to `Inner`, expected `number`.',
@ -408,7 +416,9 @@ describe('memo', () => {
// Update // Update
expect(() => { expect(() => {
ReactNoop.render( ReactNoop.render(
<Outer inner={false} middle={false} outer={false} />, <div>
<Outer inner={false} middle={false} outer={false} />
</div>,
); );
expect(Scheduler).toFlushWithoutYielding(); expect(Scheduler).toFlushWithoutYielding();
}).toErrorDev([ }).toErrorDev([

View File

@ -121,7 +121,8 @@ export function describeUnknownElementTypeFrameInDEV(
case REACT_FORWARD_REF_TYPE: case REACT_FORWARD_REF_TYPE:
return describeFunctionComponentFrame(type.render, source, ownerFn); return describeFunctionComponentFrame(type.render, source, ownerFn);
case REACT_MEMO_TYPE: case REACT_MEMO_TYPE:
return describeFunctionComponentFrame(type.type, source, ownerFn); // Memo may contain any component type so we recursively resolve it.
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
case REACT_BLOCK_TYPE: case REACT_BLOCK_TYPE:
return describeFunctionComponentFrame(type._render, source, ownerFn); return describeFunctionComponentFrame(type._render, source, ownerFn);
case REACT_LAZY_TYPE: { case REACT_LAZY_TYPE: {
@ -129,6 +130,7 @@ export function describeUnknownElementTypeFrameInDEV(
const payload = lazyComponent._payload; const payload = lazyComponent._payload;
const init = lazyComponent._init; const init = lazyComponent._init;
try { try {
// Lazy may contain any component type so we recursively resolve it.
return describeUnknownElementTypeFrameInDEV( return describeUnknownElementTypeFrameInDEV(
init(payload), init(payload),
source, source,