dillon1000/react
Commit
Browse files DevTools: Fix nested HOC name extraction in extractHOCNames (#37215)
## 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** <img width="1920" height="690" alt="devtools-hoc-BEFORE-buggy" src="https://github.com/user-attachments/assets/14e7e632-da97-43fb-867b-9da3b9d7cb22" /> **After** <img width="1920" height="690" alt="devtools-hoc-AFTER-fixed" src="https://github.com/user-attachments/assets/4fe91b78-af11-4584-986b-b7aa9a03d0b6" /> Not sure if we need a new fixture can add one if required
Changed paths2 files
First-parent comparisonpackages/react-devtools-shared/src/__tests__/extractHOCNames-test.js AddedM packages/react-devtools-shared/src/backend/views/utils.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…