[DevTools] Clean Up DevTools Code (#24782)

This PR cleans up the DevTools codebase by:
* Consolidating `normalizeCodeLocInfo` into one place
* Remove unused source argument in the DevTools component stacks code
This commit is contained in:
Luna Ruan
2022-06-23 18:47:47 -04:00
committed by GitHub
parent 9abe745aa7
commit 955cad9bcc
7 changed files with 29 additions and 59 deletions
@@ -12,7 +12,6 @@
// while still maintaining support for multiple renderer versions
// (which use different values for ReactTypeOfWork).
import type {Source} from 'shared/ReactElementType';
import type {LazyComponent} from 'react/src/ReactLazy';
import type {CurrentDispatcherRef} from './types';
@@ -36,7 +35,6 @@ import {disableLogs, reenableLogs} from './DevToolsConsolePatching';
let prefix;
export function describeBuiltInComponentFrame(
name: string,
source: void | null | Source,
ownerFn: void | null | Function,
): string {
if (prefix === undefined) {
@@ -204,7 +202,6 @@ export function describeNativeComponentFrame(
export function describeClassComponentFrame(
ctor: Function,
source: void | null | Source,
ownerFn: void | null | Function,
currentDispatcherRef: CurrentDispatcherRef,
): string {
@@ -213,7 +210,6 @@ export function describeClassComponentFrame(
export function describeFunctionComponentFrame(
fn: Function,
source: void | null | Source,
ownerFn: void | null | Function,
currentDispatcherRef: CurrentDispatcherRef,
): string {
@@ -227,7 +223,6 @@ function shouldConstruct(Component: Function) {
export function describeUnknownElementTypeFrameInDEV(
type: any,
source: void | null | Source,
ownerFn: void | null | Function,
currentDispatcherRef: CurrentDispatcherRef,
): string {
@@ -245,15 +240,15 @@ export function describeUnknownElementTypeFrameInDEV(
);
}
if (typeof type === 'string') {
return describeBuiltInComponentFrame(type, source, ownerFn);
return describeBuiltInComponentFrame(type, ownerFn);
}
switch (type) {
case SUSPENSE_NUMBER:
case SUSPENSE_SYMBOL_STRING:
return describeBuiltInComponentFrame('Suspense', source, ownerFn);
return describeBuiltInComponentFrame('Suspense', ownerFn);
case SUSPENSE_LIST_NUMBER:
case SUSPENSE_LIST_SYMBOL_STRING:
return describeBuiltInComponentFrame('SuspenseList', source, ownerFn);
return describeBuiltInComponentFrame('SuspenseList', ownerFn);
}
if (typeof type === 'object') {
switch (type.$$typeof) {
@@ -261,7 +256,6 @@ export function describeUnknownElementTypeFrameInDEV(
case FORWARD_REF_SYMBOL_STRING:
return describeFunctionComponentFrame(
type.render,
source,
ownerFn,
currentDispatcherRef,
);
@@ -270,7 +264,6 @@ export function describeUnknownElementTypeFrameInDEV(
// Memo may contain any component type so we recursively resolve it.
return describeUnknownElementTypeFrameInDEV(
type.type,
source,
ownerFn,
currentDispatcherRef,
);
@@ -283,7 +276,6 @@ export function describeUnknownElementTypeFrameInDEV(
// Lazy may contain any component type so we recursively resolve it.
return describeUnknownElementTypeFrameInDEV(
init(payload),
source,
ownerFn,
currentDispatcherRef,
);