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

Function updateSlot

code/redux/public/app.js:9367–9423  ·  view source on GitHub ↗
(returnFiber, oldFiber, newChild, expirationTime)

Source from the content-addressed store, hash-verified

9365 }
9366
9367 function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
9368 // Update the fiber if the keys match, otherwise return null.
9369
9370 var key = oldFiber !== null ? oldFiber.key : null;
9371
9372 if (typeof newChild === 'string' || typeof newChild === 'number') {
9373 // Text nodes don't have keys. If the previous node is implicitly keyed
9374 // we can continue to replace it without aborting even if it is not a text
9375 // node.
9376 if (key !== null) {
9377 return null;
9378 }
9379 return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
9380 }
9381
9382 if (typeof newChild === 'object' && newChild !== null) {
9383 switch (newChild.$$typeof) {
9384 case REACT_ELEMENT_TYPE:
9385 {
9386 if (newChild.key === key) {
9387 if (newChild.type === REACT_FRAGMENT_TYPE) {
9388 return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
9389 }
9390 return updateElement(returnFiber, oldFiber, newChild, expirationTime);
9391 } else {
9392 return null;
9393 }
9394 }
9395 case REACT_PORTAL_TYPE:
9396 {
9397 if (newChild.key === key) {
9398 return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
9399 } else {
9400 return null;
9401 }
9402 }
9403 }
9404
9405 if (isArray$1(newChild) || getIteratorFn(newChild)) {
9406 if (key !== null) {
9407 return null;
9408 }
9409
9410 return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
9411 }
9412
9413 throwOnInvalidObjectType(returnFiber, newChild);
9414 }
9415
9416 {
9417 if (typeof newChild === 'function') {
9418 warnOnFunctionType();
9419 }
9420 }
9421
9422 return null;
9423 }
9424

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