Skip to content

DevTools: Fix nested HOC name extraction in extractHOCNames - #37215

Merged
hoxyq merged 3 commits into
react:mainfrom
Biki-das:devtools-hoc
Aug 6, 2026
Merged

DevTools: Fix nested HOC name extraction in extractHOCNames#37215
hoxyq merged 3 commits into
react:mainfrom
Biki-das:devtools-hoc

Conversation

@Biki-das

@Biki-das Biki-das commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

There was a bug in the helper that unwraps component names like Forget(Memo(Button)) into a base component name plus its HOC wrappers. The regex was using the g flag, which means exec() remembers its position via lastIndex. Since each iteration replaces the current string with the shorter unwrapped inner string, lastIndex ends up pointing past the end of the new string. The next exec() returns null, so the loop stops after unwrapping only the outermost HOC.

component named Forget(Memo(ForgetMemoCounter))
before fixes ✨Memo(ForgetMemoCounter)
after fixes ✨🧠ForgetMemoCounter

component named Forget(ForwardRef(ForgetForwardRefCounter))
before fixes ✨ForwardRef(ForgetForwardRefCounter)
after fixes ✨ForgetForwardRefCounter

How did you test this change?

Tested the change locally in devtool and added tests for the same

Before
devtools-hoc-BEFORE-buggy

After
devtools-hoc-AFTER-fixed

Not sure if we need a new fixture can add one if required

@meta-cla meta-cla Bot added the CLA Signed label Aug 5, 2026
@Biki-das

Biki-das commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

cc @hoxyq

@hoxyq
hoxyq merged commit ec61f18 into react:main Aug 6, 2026
238 checks passed
@Biki-das
Biki-das deleted the devtools-hoc branch August 6, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants