mirror of
https://github.com/facebook/react.git
synced 2026-02-21 19:31:52 +00:00
[DevTools] Allow renaming Host Component props (#35735)
This commit is contained in:
committed by
GitHub
parent
4c9d62d2b4
commit
6a939d0b54
@@ -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
|
||||
|
||||
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user