MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / updateFromMap

Function updateFromMap

code/controlled-uncontrolled/public/app.js:8498–8538  ·  view source on GitHub ↗
(existingChildren, returnFiber, newIdx, newChild, expirationTime)

Source from the content-addressed store, hash-verified

8496 }
8497
8498 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
8499 if (typeof newChild === 'string' || typeof newChild === 'number') {
8500 // Text nodes don't have keys, so we neither have to check the old nor
8501 // new node for the key. If both are text nodes, they match.
8502 var matchedFiber = existingChildren.get(newIdx) || null;
8503 return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
8504 }
8505
8506 if (typeof newChild === 'object' && newChild !== null) {
8507 switch (newChild.$$typeof) {
8508 case REACT_ELEMENT_TYPE:
8509 {
8510 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
8511 if (newChild.type === REACT_FRAGMENT_TYPE) {
8512 return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
8513 }
8514 return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
8515 }
8516 case REACT_PORTAL_TYPE:
8517 {
8518 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
8519 return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
8520 }
8521 }
8522
8523 if (isArray$1(newChild) || getIteratorFn(newChild)) {
8524 var _matchedFiber3 = existingChildren.get(newIdx) || null;
8525 return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
8526 }
8527
8528 throwOnInvalidObjectType(returnFiber, newChild);
8529 }
8530
8531 {
8532 if (typeof newChild === 'function') {
8533 warnOnFunctionType();
8534 }
8535 }
8536
8537 return null;
8538 }
8539
8540 /**
8541 * Warns if there is a duplicate or missing key

Callers 2

reconcileChildrenArrayFunction · 0.70

Calls 7

updateTextNodeFunction · 0.70
updateFragmentFunction · 0.70
updateElementFunction · 0.70
updatePortalFunction · 0.70
getIteratorFnFunction · 0.70
throwOnInvalidObjectTypeFunction · 0.70
warnOnFunctionTypeFunction · 0.70

Tested by

no test coverage detected