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

Function updateSlot

code/one-direction-data-flow/public/app.js:8989–9045  ·  view source on GitHub ↗
(returnFiber, oldFiber, newChild, expirationTime)

Source from the content-addressed store, hash-verified

8987 }
8988
8989 function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
8990 // Update the fiber if the keys match, otherwise return null.
8991
8992 var key = oldFiber !== null ? oldFiber.key : null;
8993
8994 if (typeof newChild === 'string' || typeof newChild === 'number') {
8995 // Text nodes don't have keys. If the previous node is implicitly keyed
8996 // we can continue to replace it without aborting even if it is not a text
8997 // node.
8998 if (key !== null) {
8999 return null;
9000 }
9001 return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
9002 }
9003
9004 if (typeof newChild === 'object' && newChild !== null) {
9005 switch (newChild.$$typeof) {
9006 case REACT_ELEMENT_TYPE:
9007 {
9008 if (newChild.key === key) {
9009 if (newChild.type === REACT_FRAGMENT_TYPE) {
9010 return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
9011 }
9012 return updateElement(returnFiber, oldFiber, newChild, expirationTime);
9013 } else {
9014 return null;
9015 }
9016 }
9017 case REACT_PORTAL_TYPE:
9018 {
9019 if (newChild.key === key) {
9020 return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
9021 } else {
9022 return null;
9023 }
9024 }
9025 }
9026
9027 if (isArray$1(newChild) || getIteratorFn(newChild)) {
9028 if (key !== null) {
9029 return null;
9030 }
9031
9032 return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
9033 }
9034
9035 throwOnInvalidObjectType(returnFiber, newChild);
9036 }
9037
9038 {
9039 if (typeof newChild === 'function') {
9040 warnOnFunctionType();
9041 }
9042 }
9043
9044 return null;
9045 }
9046

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