Exclude forwardRef and memo from stack frames by sebmarkbage · Pull Request #18559 · react/react (original) (raw)

Conversation

@sebmarkbage

We can't patch the row with the new trick. So they won't be called Memo(Name) in the stack anymore.

We could give these their own "built-in" stack frame since they're conceptually HoCs. I.e.

However, from a debugging perspective this is not very useful meta data and quite noisy. So I'm just going to exclude them.

@codesandbox-ci

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit e1885ab:

Sandbox Source
sweet-elion-wcqiv Configuration

@gaearon

sebmarkbage

case REACT_FORWARD_REF_TYPE:
return describeFunctionComponentFrame(type.render, source, ownerFn);
case REACT_MEMO_TYPE:
return describeFunctionComponentFrame(type.type, source, ownerFn);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was also a bug because the inner one might not be a function.

sebmarkbage

,
,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning no longer includes any stack because there's only a Memo. This triggers our internal warning about not expecting a stack on the warning. However, that's not realistic so let's test it with a stack.

@sizebot

No significant bundle size changes to report.

Size changes (stable)

Generated by 🚫 dangerJS against e1885ab

@sebmarkbage

I kept SimpleMemoComponent and ForwardRef in the Fiber describing thing but they just describe their function name. It's only one Fiber for both the function and wrapper. I removed Memo because it's not the actual function, the function is represented by its own Fiber as a child so it's already there.

For elements I was already doing this by only naming the function.

gaearon

gaearon

@sebmarkbage

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.

@sizebot

No significant bundle size changes to report.

Size changes (experimental)

Generated by 🚫 dangerJS against e1885ab

This was referenced

Mar 6, 2021

This was referenced

Mar 14, 2021

This was referenced

Mar 15, 2021

This was referenced

Sep 8, 2024

This was referenced

Sep 20, 2024

This was referenced

Oct 1, 2024

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

Labels