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
B
BIKI DAS committed
ec61f187fe39b0aa8ec6b508f2553b2047dc30cc
Parent: 1d4758e
Committed by GitHub <noreply@github.com>
on 8/6/2026, 12:44:04 PM