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

Function updateFromMap

code/higher-order-components/public/app.js:9168–9208  ·  view source on GitHub ↗
(existingChildren, returnFiber, newIdx, newChild, expirationTime)

Source from the content-addressed store, hash-verified

9166 }
9167
9168 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
9169 if (typeof newChild === 'string' || typeof newChild === 'number') {
9170 // Text nodes don't have keys, so we neither have to check the old nor
9171 // new node for the key. If both are text nodes, they match.
9172 var matchedFiber = existingChildren.get(newIdx) || null;
9173 return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
9174 }
9175
9176 if (typeof newChild === 'object' && newChild !== null) {
9177 switch (newChild.$$typeof) {
9178 case REACT_ELEMENT_TYPE:
9179 {
9180 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
9181 if (newChild.type === REACT_FRAGMENT_TYPE) {
9182 return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
9183 }
9184 return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
9185 }
9186 case REACT_PORTAL_TYPE:
9187 {
9188 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
9189 return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
9190 }
9191 }
9192
9193 if (isArray$1(newChild) || getIteratorFn(newChild)) {
9194 var _matchedFiber3 = existingChildren.get(newIdx) || null;
9195 return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
9196 }
9197
9198 throwOnInvalidObjectType(returnFiber, newChild);
9199 }
9200
9201 {
9202 if (typeof newChild === 'function') {
9203 warnOnFunctionType();
9204 }
9205 }
9206
9207 return null;
9208 }
9209
9210 /**
9211 * 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