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

Function updateSlot

code/higher-order-components/public/app.js:9110–9166  ·  view source on GitHub ↗
(returnFiber, oldFiber, newChild, expirationTime)

Source from the content-addressed store, hash-verified

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

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