Skip to content

[refactor] clean up describeNativeComponentFrame #31781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading