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

Function updateSlot

code/controlled-uncontrolled/public/app.js:8440–8496  ·  view source on GitHub ↗
(returnFiber, oldFiber, newChild, expirationTime)

Source from the content-addressed store, hash-verified

8438 }
8439
8440 function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
8441 // Update the fiber if the keys match, otherwise return null.
8442
8443 var key = oldFiber !== null ? oldFiber.key : null;
8444
8445 if (typeof newChild === 'string' || typeof newChild === 'number') {
8446 // Text nodes don't have keys. If the previous node is implicitly keyed
8447 // we can continue to replace it without aborting even if it is not a text
8448 // node.
8449 if (key !== null) {
8450 return null;
8451 }
8452 return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
8453 }
8454
8455 if (typeof newChild === 'object' && newChild !== null) {
8456 switch (newChild.$$typeof) {
8457 case REACT_ELEMENT_TYPE:
8458 {
8459 if (newChild.key === key) {
8460 if (newChild.type === REACT_FRAGMENT_TYPE) {
8461 return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
8462 }
8463 return updateElement(returnFiber, oldFiber, newChild, expirationTime);
8464 } else {
8465 return null;
8466 }
8467 }
8468 case REACT_PORTAL_TYPE:
8469 {
8470 if (newChild.key === key) {
8471 return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
8472 } else {
8473 return null;
8474 }
8475 }
8476 }
8477
8478 if (isArray$1(newChild) || getIteratorFn(newChild)) {
8479 if (key !== null) {
8480 return null;
8481 }
8482
8483 return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
8484 }
8485
8486 throwOnInvalidObjectType(returnFiber, newChild);
8487 }
8488
8489 {
8490 if (typeof newChild === 'function') {
8491 warnOnFunctionType();
8492 }
8493 }
8494
8495 return null;
8496 }
8497

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