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

Function updateSlot

code/communication/public/app.js:9151–9207  ·  view source on GitHub ↗
(returnFiber, oldFiber, newChild, expirationTime)

Source from the content-addressed store, hash-verified

9149 }
9150
9151 function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
9152 // Update the fiber if the keys match, otherwise return null.
9153
9154 var key = oldFiber !== null ? oldFiber.key : null;
9155
9156 if (typeof newChild === 'string' || typeof newChild === 'number') {
9157 // Text nodes don't have keys. If the previous node is implicitly keyed
9158 // we can continue to replace it without aborting even if it is not a text
9159 // node.
9160 if (key !== null) {
9161 return null;
9162 }
9163 return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
9164 }
9165
9166 if (typeof newChild === 'object' && newChild !== null) {
9167 switch (newChild.$$typeof) {
9168 case REACT_ELEMENT_TYPE:
9169 {
9170 if (newChild.key === key) {
9171 if (newChild.type === REACT_FRAGMENT_TYPE) {
9172 return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
9173 }
9174 return updateElement(returnFiber, oldFiber, newChild, expirationTime);
9175 } else {
9176 return null;
9177 }
9178 }
9179 case REACT_PORTAL_TYPE:
9180 {
9181 if (newChild.key === key) {
9182 return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
9183 } else {
9184 return null;
9185 }
9186 }
9187 }
9188
9189 if (isArray$1(newChild) || getIteratorFn(newChild)) {
9190 if (key !== null) {
9191 return null;
9192 }
9193
9194 return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
9195 }
9196
9197 throwOnInvalidObjectType(returnFiber, newChild);
9198 }
9199
9200 {
9201 if (typeof newChild === 'function') {
9202 warnOnFunctionType();
9203 }
9204 }
9205
9206 return null;
9207 }
9208

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