@samitouri / QOS-React-2 / commits / 6a939d0b54

[DevTools] Allow renaming Host Component props (#35735)

Sebastian "Sebbie" Silbermann committed Feb 9, 2026 at 23:14 UTC 6a939d0b54a0e1aded58652a307cfc083b691d67
2 files changed +28 -12
packages/react-devtools-shared/src/__tests__/editing-test.js
+14 -1
@@ -82,7 +82,12 @@ describe('editing interface', () => {
82 shallow="initial"
83 />
84 ,
85 - <input ref={inputRef} onChange={jest.fn()} value="initial" />
85 + <input
86 + ref={inputRef}
87 + onChange={jest.fn()}
88 + value="initial"
89 + data-foo="test"
90 + />
91 </>,
92 ),
93 );
@@ -259,6 +264,14 @@ describe('editing interface', () => {
264 },
265 after: 'initial',
266 });
267 + renamePath(hostComponentID, ['data-foo'], ['data-bar']);
268 + expect({
269 + foo: inputRef.current.dataset.foo,
270 + bar: inputRef.current.dataset.bar,
271 + }).toEqual({
272 + foo: undefined,
273 + bar: 'test',
274 + });
275 });
276
277 // @reactVersion >= 16.9
packages/react-devtools-shared/src/backend/fiber/renderer.js
+14 -11
@@ -7874,17 +7874,20 @@ export function attach(
7874 }
7875 break;
7876 case 'props':
7877 - if (instance === null) {
7878 - if (typeof overridePropsRenamePath === 'function') {
7879 - overridePropsRenamePath(fiber, oldPath, newPath);
7880 - }
7881 - } else {
7882 - fiber.pendingProps = copyWithRename(
7883 - instance.props,
7884 - oldPath,
7885 - newPath,
7886 - );
7887 - instance.forceUpdate();
7877 + switch (fiber.tag) {
7878 + case ClassComponent:
7879 + fiber.pendingProps = copyWithRename(
7880 + instance.props,
7881 + oldPath,
7882 + newPath,
7883 + );
7884 + instance.forceUpdate();
7885 + break;
7886 + default:
7887 + if (typeof overridePropsRenamePath === 'function') {
7888 + overridePropsRenamePath(fiber, oldPath, newPath);
7889 + }
7890 + break;
7891 }
7892 break;
7893 case 'state':