Skip to content

Commit 5d26f17

Browse files
committed
Restore cloneAndReplaceKey changes
1 parent 63f6541 commit 5d26f17

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/react/src/jsx/ReactJSXElement.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ export function createElement(type, config, children) {
953953
}
954954

955955
export function cloneAndReplaceKey(oldElement, newKey) {
956-
return ReactElement(
956+
const clonedElement = ReactElement(
957957
oldElement.type,
958958
newKey,
959959
// When enableRefAsProp is on, this argument is ignored. This check only
@@ -966,6 +966,11 @@ export function cloneAndReplaceKey(oldElement, newKey) {
966966
__DEV__ && enableOwnerStacks ? oldElement._debugStack : undefined,
967967
__DEV__ && enableOwnerStacks ? oldElement._debugTask : undefined,
968968
);
969+
if (__DEV__) {
970+
// The cloned element should inherit the original element's key validation.
971+
clonedElement._store.validated = oldElement._store.validated;
972+
}
973+
return clonedElement;
969974
}
970975

971976
/**

0 commit comments

Comments
 (0)