MCPcopy Index your code
hub / github.com/krasimir/react-in-patterns / updateFromMap

Function updateFromMap

code/new-context-api/public/app.js:8535–8575  ·  view source on GitHub ↗
(existingChildren, returnFiber, newIdx, newChild, expirationTime)

Source from the content-addressed store, hash-verified

8533 }
8534
8535 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
8536 if (typeof newChild === 'string' || typeof newChild === 'number') {
8537 // Text nodes don't have keys, so we neither have to check the old nor
8538 // new node for the key. If both are text nodes, they match.
8539 var matchedFiber = existingChildren.get(newIdx) || null;
8540 return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
8541 }
8542
8543 if (typeof newChild === 'object' && newChild !== null) {
8544 switch (newChild.$$typeof) {
8545 case REACT_ELEMENT_TYPE:
8546 {
8547 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
8548 if (newChild.type === REACT_FRAGMENT_TYPE) {
8549 return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
8550 }
8551 return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
8552 }
8553 case REACT_PORTAL_TYPE:
8554 {
8555 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
8556 return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
8557 }
8558 }
8559
8560 if (isArray$1(newChild) || getIteratorFn(newChild)) {
8561 var _matchedFiber3 = existingChildren.get(newIdx) || null;
8562 return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
8563 }
8564
8565 throwOnInvalidObjectType(returnFiber, newChild);
8566 }
8567
8568 {
8569 if (typeof newChild === 'function') {
8570 warnOnFunctionType();
8571 }
8572 }
8573
8574 return null;
8575 }
8576
8577 /**
8578 * 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