MCPcopy Create free account
hub / github.com/reactjs/react-rails / updateFromMap

Function updateFromMap

lib/assets/react-source/development/react.js:17418–17463  ·  view source on GitHub ↗
(existingChildren, returnFiber, newIdx, newChild, expirationTime)

Source from the content-addressed store, hash-verified

17416 }
17417
17418 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
17419 if (typeof newChild === 'string' || typeof newChild === 'number') {
17420 // Text nodes don't have keys, so we neither have to check the old nor
17421 // new node for the key. If both are text nodes, they match.
17422 var matchedFiber = existingChildren.get(newIdx) || null;
17423 return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
17424 }
17425
17426 if (typeof newChild === 'object' && newChild !== null) {
17427 switch (newChild.$$typeof) {
17428 case REACT_ELEMENT_TYPE:
17429 {
17430 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
17431
17432 if (newChild.type === REACT_FRAGMENT_TYPE) {
17433 return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
17434 }
17435
17436 return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
17437 }
17438
17439 case REACT_PORTAL_TYPE:
17440 {
17441 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
17442
17443 return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
17444 }
17445 }
17446
17447 if (isArray$1(newChild) || getIteratorFn(newChild)) {
17448 var _matchedFiber3 = existingChildren.get(newIdx) || null;
17449
17450 return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
17451 }
17452
17453 throwOnInvalidObjectType(returnFiber, newChild);
17454 }
17455
17456 {
17457 if (typeof newChild === 'function') {
17458 warnOnFunctionType();
17459 }
17460 }
17461
17462 return null;
17463 }
17464 /**
17465 * Warns if there is a duplicate or missing key
17466 */

Callers 2

reconcileChildrenArrayFunction · 0.85

Calls 7

updateTextNodeFunction · 0.85
updateFragmentFunction · 0.85
updateElementFunction · 0.85
updatePortalFunction · 0.85
throwOnInvalidObjectTypeFunction · 0.85
warnOnFunctionTypeFunction · 0.85
getIteratorFnFunction · 0.70

Tested by

no test coverage detected