Skip to content

Commit

Permalink
[refactor] clean up describeNativeComponentFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Dec 14, 2024
1 parent 9e2c233 commit 5575e5c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if (__DEV__) {
componentFrameCache = new PossiblyWeakMap<$FlowFixMe, string>();
}

export function describeNativeComponentFrame(
export function describeFunctionComponentFrame(
fn: Function,
construct: boolean,
currentDispatcherRef: CurrentDispatcherRef,
Expand Down Expand Up @@ -280,12 +280,5 @@ export function describeClassComponentFrame(
ctor: Function,
currentDispatcherRef: CurrentDispatcherRef,
): string {
return describeNativeComponentFrame(ctor, true, currentDispatcherRef);
}

export function describeFunctionComponentFrame(
fn: Function,
currentDispatcherRef: CurrentDispatcherRef,
): string {
return describeNativeComponentFrame(fn, false, currentDispatcherRef);
return describeFunctionComponentFrame(ctor, true, currentDispatcherRef);
}
10 changes: 3 additions & 7 deletions packages/shared/ReactComponentStackFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ if (__DEV__) {
* (3) diffing the control and sample error stacks to find the stack frame
* which represents our component.
*/
export function describeNativeComponentFrame(
export function describeFunctionComponentFrame(
fn: Function,
construct: boolean,
): string {
Expand Down Expand Up @@ -291,11 +291,7 @@ export function describeNativeComponentFrame(
}

export function describeClassComponentFrame(ctor: Function): string {
return describeNativeComponentFrame(ctor, true);
}

export function describeFunctionComponentFrame(fn: Function): string {
return describeNativeComponentFrame(fn, false);
return describeFunctionComponentFrame(ctor, true);
}

function shouldConstruct(Component: Function) {
Expand All @@ -312,7 +308,7 @@ export function describeUnknownElementTypeFrameInDEV(type: any): string {
return '';
}
if (typeof type === 'function') {
return describeNativeComponentFrame(type, shouldConstruct(type));
return describeFunctionComponentFrame(type, shouldConstruct(type));
}
if (typeof type === 'string') {
return describeBuiltInComponentFrame(type);
Expand Down

0 comments on commit 5575e5c

Please sign in to comment.