mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
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.
70 lines
1.9 KiB
JavaScript
70 lines
1.9 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
*/
|
|
|
|
import type {Fiber} from './ReactInternalTypes';
|
|
|
|
import {
|
|
HostComponent,
|
|
LazyComponent,
|
|
SuspenseComponent,
|
|
SuspenseListComponent,
|
|
FunctionComponent,
|
|
IndeterminateComponent,
|
|
ForwardRef,
|
|
SimpleMemoComponent,
|
|
Block,
|
|
ClassComponent,
|
|
} from './ReactWorkTags';
|
|
import {
|
|
describeBuiltInComponentFrame,
|
|
describeFunctionComponentFrame,
|
|
describeClassComponentFrame,
|
|
} from 'shared/ReactComponentStackFrame';
|
|
|
|
function describeFiber(fiber: Fiber): string {
|
|
const owner: null | Function = __DEV__
|
|
? fiber._debugOwner
|
|
? fiber._debugOwner.type
|
|
: null
|
|
: null;
|
|
const source = __DEV__ ? fiber._debugSource : null;
|
|
switch (fiber.tag) {
|
|
case HostComponent:
|
|
return describeBuiltInComponentFrame(fiber.type, source, owner);
|
|
case LazyComponent:
|
|
return describeBuiltInComponentFrame('Lazy', source, owner);
|
|
case SuspenseComponent:
|
|
return describeBuiltInComponentFrame('Suspense', source, owner);
|
|
case SuspenseListComponent:
|
|
return describeBuiltInComponentFrame('SuspenseList', source, owner);
|
|
case FunctionComponent:
|
|
case IndeterminateComponent:
|
|
case SimpleMemoComponent:
|
|
return describeFunctionComponentFrame(fiber.type, source, owner);
|
|
case ForwardRef:
|
|
return describeFunctionComponentFrame(fiber.type.render, source, owner);
|
|
case Block:
|
|
return describeFunctionComponentFrame(fiber.type._render, source, owner);
|
|
case ClassComponent:
|
|
return describeClassComponentFrame(fiber.type, source, owner);
|
|
default:
|
|
return '';
|
|
}
|
|
}
|
|
|
|
export function getStackByFiberInDevAndProd(workInProgress: Fiber): string {
|
|
let info = '';
|
|
let node = workInProgress;
|
|
do {
|
|
info += describeFiber(node);
|
|
node = node.return;
|
|
} while (node);
|
|
return info;
|
|
}
|