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

Function updateSlot

code/styling/public/app.js:9116–9172  ·  view source on GitHub ↗
(returnFiber, oldFiber, newChild, expirationTime)

Source from the content-addressed store, hash-verified

9114 }
9115
9116 function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
9117 // Update the fiber if the keys match, otherwise return null.
9118
9119 var key = oldFiber !== null ? oldFiber.key : null;
9120
9121 if (typeof newChild === 'string' || typeof newChild === 'number') {
9122 // Text nodes don't have keys. If the previous node is implicitly keyed
9123 // we can continue to replace it without aborting even if it is not a text
9124 // node.
9125 if (key !== null) {
9126 return null;
9127 }
9128 return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
9129 }
9130
9131 if (typeof newChild === 'object' && newChild !== null) {
9132 switch (newChild.$$typeof) {
9133 case REACT_ELEMENT_TYPE:
9134 {
9135 if (newChild.key === key) {
9136 if (newChild.type === REACT_FRAGMENT_TYPE) {
9137 return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
9138 }
9139 return updateElement(returnFiber, oldFiber, newChild, expirationTime);
9140 } else {
9141 return null;
9142 }
9143 }
9144 case REACT_PORTAL_TYPE:
9145 {
9146 if (newChild.key === key) {
9147 return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
9148 } else {
9149 return null;
9150 }
9151 }
9152 }
9153
9154 if (isArray$1(newChild) || getIteratorFn(newChild)) {
9155 if (key !== null) {
9156 return null;
9157 }
9158
9159 return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
9160 }
9161
9162 throwOnInvalidObjectType(returnFiber, newChild);
9163 }
9164
9165 {
9166 if (typeof newChild === 'function') {
9167 warnOnFunctionType();
9168 }
9169 }
9170
9171 return null;
9172 }
9173

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