MCPcopy Create free account
hub / github.com/reactjs/react-rails / updateSlot

Function updateSlot

lib/assets/react-source/development/react.js:17358–17416  ·  view source on GitHub ↗
(returnFiber, oldFiber, newChild, expirationTime)

Source from the content-addressed store, hash-verified

17356 }
17357
17358 function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
17359 // Update the fiber if the keys match, otherwise return null.
17360 var key = oldFiber !== null ? oldFiber.key : null;
17361
17362 if (typeof newChild === 'string' || typeof newChild === 'number') {
17363 // Text nodes don't have keys. If the previous node is implicitly keyed
17364 // we can continue to replace it without aborting even if it is not a text
17365 // node.
17366 if (key !== null) {
17367 return null;
17368 }
17369
17370 return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
17371 }
17372
17373 if (typeof newChild === 'object' && newChild !== null) {
17374 switch (newChild.$$typeof) {
17375 case REACT_ELEMENT_TYPE:
17376 {
17377 if (newChild.key === key) {
17378 if (newChild.type === REACT_FRAGMENT_TYPE) {
17379 return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
17380 }
17381
17382 return updateElement(returnFiber, oldFiber, newChild, expirationTime);
17383 } else {
17384 return null;
17385 }
17386 }
17387
17388 case REACT_PORTAL_TYPE:
17389 {
17390 if (newChild.key === key) {
17391 return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
17392 } else {
17393 return null;
17394 }
17395 }
17396 }
17397
17398 if (isArray$1(newChild) || getIteratorFn(newChild)) {
17399 if (key !== null) {
17400 return null;
17401 }
17402
17403 return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
17404 }
17405
17406 throwOnInvalidObjectType(returnFiber, newChild);
17407 }
17408
17409 {
17410 if (typeof newChild === 'function') {
17411 warnOnFunctionType();
17412 }
17413 }
17414
17415 return null;

Callers 2

reconcileChildrenArrayFunction · 0.85

Calls 7

updateTextNodeFunction · 0.85
updateFragmentFunction · 0.85
updateElementFunction · 0.85
updatePortalFunction · 0.85
throwOnInvalidObjectTypeFunction · 0.85
warnOnFunctionTypeFunction · 0.85
getIteratorFnFunction · 0.70

Tested by

no test coverage detected