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

Function updateFromMap

code/one-direction-data-flow/public/app.js:9047–9087  ·  view source on GitHub ↗
(existingChildren, returnFiber, newIdx, newChild, expirationTime)

Source from the content-addressed store, hash-verified

9045 }
9046
9047 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
9048 if (typeof newChild === 'string' || typeof newChild === 'number') {
9049 // Text nodes don't have keys, so we neither have to check the old nor
9050 // new node for the key. If both are text nodes, they match.
9051 var matchedFiber = existingChildren.get(newIdx) || null;
9052 return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
9053 }
9054
9055 if (typeof newChild === 'object' && newChild !== null) {
9056 switch (newChild.$$typeof) {
9057 case REACT_ELEMENT_TYPE:
9058 {
9059 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
9060 if (newChild.type === REACT_FRAGMENT_TYPE) {
9061 return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
9062 }
9063 return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
9064 }
9065 case REACT_PORTAL_TYPE:
9066 {
9067 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
9068 return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
9069 }
9070 }
9071
9072 if (isArray$1(newChild) || getIteratorFn(newChild)) {
9073 var _matchedFiber3 = existingChildren.get(newIdx) || null;
9074 return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
9075 }
9076
9077 throwOnInvalidObjectType(returnFiber, newChild);
9078 }
9079
9080 {
9081 if (typeof newChild === 'function') {
9082 warnOnFunctionType();
9083 }
9084 }
9085
9086 return null;
9087 }
9088
9089 /**
9090 * 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