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

Function updateFromMap

code/event-handlers/public/app.js:8504–8544  ·  view source on GitHub ↗
(existingChildren, returnFiber, newIdx, newChild, expirationTime)

Source from the content-addressed store, hash-verified

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