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"
|
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',
|
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
|
// @reactVersion >= 16.9
|
||||||
|
|||||||
@@ -7874,17 +7874,20 @@ export function attach(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'props':
|
case 'props':
|
||||||
if (instance === null) {
|
switch (fiber.tag) {
|
||||||
if (typeof overridePropsRenamePath === 'function') {
|
case ClassComponent:
|
||||||
overridePropsRenamePath(fiber, oldPath, newPath);
|
fiber.pendingProps = copyWithRename(
|
||||||
}
|
instance.props,
|
||||||
} else {
|
oldPath,
|
||||||
fiber.pendingProps = copyWithRename(
|
newPath,
|
||||||
instance.props,
|
);
|
||||||
oldPath,
|
instance.forceUpdate();
|
||||||
newPath,
|
break;
|
||||||
);
|
default:
|
||||||
instance.forceUpdate();
|
if (typeof overridePropsRenamePath === 'function') {
|
||||||
|
overridePropsRenamePath(fiber, oldPath, newPath);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'state':
|
case 'state':
|
||||||
|
|||||||
Reference in New Issue
Block a user