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

This commit is contained in:
Sebastian "Sebbie" Silbermann
2026-02-09 23:14:46 +01:00
committed by GitHub
parent 4c9d62d2b4
commit 6a939d0b54
2 changed files with 28 additions and 12 deletions

View File

@@ -82,7 +82,12 @@ describe('editing interface', () => {
shallow="initial"
/>
,
<input ref={inputRef} onChange={jest.fn()} value="initial" />
<input
ref={inputRef}
onChange={jest.fn()}
value="initial"
data-foo="test"
/>
</>,
),
);
@@ -259,6 +264,14 @@ describe('editing interface', () => {
},
after: 'initial',
});
renamePath(hostComponentID, ['data-foo'], ['data-bar']);
expect({
foo: inputRef.current.dataset.foo,
bar: inputRef.current.dataset.bar,
}).toEqual({
foo: undefined,
bar: 'test',
});
});
// @reactVersion >= 16.9

View File

@@ -7874,17 +7874,20 @@ export function attach(
}
break;
case 'props':
if (instance === null) {
if (typeof overridePropsRenamePath === 'function') {
overridePropsRenamePath(fiber, oldPath, newPath);
}
} else {
fiber.pendingProps = copyWithRename(
instance.props,
oldPath,
newPath,
);
instance.forceUpdate();
switch (fiber.tag) {
case ClassComponent:
fiber.pendingProps = copyWithRename(
instance.props,
oldPath,
newPath,
);
instance.forceUpdate();
break;
default:
if (typeof overridePropsRenamePath === 'function') {
overridePropsRenamePath(fiber, oldPath, newPath);
}
break;
}
break;
case 'state':