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

Function updateFromMap

code/communication/public/app.js:9209–9249  ·  view source on GitHub ↗
(existingChildren, returnFiber, newIdx, newChild, expirationTime)

Source from the content-addressed store, hash-verified

9207 }
9208
9209 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
9210 if (typeof newChild === 'string' || typeof newChild === 'number') {
9211 // Text nodes don't have keys, so we neither have to check the old nor
9212 // new node for the key. If both are text nodes, they match.
9213 var matchedFiber = existingChildren.get(newIdx) || null;
9214 return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
9215 }
9216
9217 if (typeof newChild === 'object' && newChild !== null) {
9218 switch (newChild.$$typeof) {
9219 case REACT_ELEMENT_TYPE:
9220 {
9221 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
9222 if (newChild.type === REACT_FRAGMENT_TYPE) {
9223 return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
9224 }
9225 return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
9226 }
9227 case REACT_PORTAL_TYPE:
9228 {
9229 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
9230 return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
9231 }
9232 }
9233
9234 if (isArray$1(newChild) || getIteratorFn(newChild)) {
9235 var _matchedFiber3 = existingChildren.get(newIdx) || null;
9236 return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
9237 }
9238
9239 throwOnInvalidObjectType(returnFiber, newChild);
9240 }
9241
9242 {
9243 if (typeof newChild === 'function') {
9244 warnOnFunctionType();
9245 }
9246 }
9247
9248 return null;
9249 }
9250
9251 /**
9252 * 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