MCPcopy
hub / github.com/facebook/react / cloneAndReplaceKey

Function cloneAndReplaceKey

packages/react/src/jsx/ReactJSXElement.js:686–702  ·  packages/react/src/jsx/ReactJSXElement.js::cloneAndReplaceKey
(oldElement, newKey)

Source from the content-addressed store, hash-verified

684}
685
686export function cloneAndReplaceKey(oldElement, newKey) {
687 const clonedElement = ReactElement(
688 oldElement.type,
689 newKey,
690 oldElement.props,
691 !__DEV__ ? undefined : oldElement._owner,
692 __DEV__ && oldElement._debugStack,
693 __DEV__ && oldElement._debugTask,
694 );
695 if (__DEV__) {
696 class="cm">// The cloned element should inherit the original element's key validation.
697 if (oldElement._store) {
698 clonedElement._store.validated = oldElement._store.validated;
699 }
700 }
701 return clonedElement;
702}
703
704/**
705 * Clone and return a new ReactElement using element as the starting point.

Callers 1

mapIntoArrayFunction · 0.90

Calls 1

ReactElementFunction · 0.70

Tested by

no test coverage detected