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

Function reconcileChildFibers

code/styling/public/app.js:9622–9696  ·  view source on GitHub ↗
(returnFiber, currentFirstChild, newChild, expirationTime)

Source from the content-addressed store, hash-verified

9620 // itself. They will be added to the side-effect list as we pass through the
9621 // children and the parent.
9622 function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {
9623 // This function is not recursive.
9624 // If the top level item is an array, we treat it as a set of children,
9625 // not as a fragment. Nested arrays on the other hand will be treated as
9626 // fragment nodes. Recursion happens at the normal flow.
9627
9628 // Handle top level unkeyed fragments as if they were arrays.
9629 // This leads to an ambiguity between <>{[...]}</> and <>...</>.
9630 // We treat the ambiguous cases above the same.
9631 if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {
9632 newChild = newChild.props.children;
9633 }
9634
9635 // Handle object types
9636 var isObject = typeof newChild === 'object' && newChild !== null;
9637
9638 if (isObject) {
9639 switch (newChild.$$typeof) {
9640 case REACT_ELEMENT_TYPE:
9641 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));
9642 case REACT_PORTAL_TYPE:
9643 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));
9644 }
9645 }
9646
9647 if (typeof newChild === 'string' || typeof newChild === 'number') {
9648 return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));
9649 }
9650
9651 if (isArray$1(newChild)) {
9652 return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);
9653 }
9654
9655 if (getIteratorFn(newChild)) {
9656 return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);
9657 }
9658
9659 if (isObject) {
9660 throwOnInvalidObjectType(returnFiber, newChild);
9661 }
9662
9663 {
9664 if (typeof newChild === 'function') {
9665 warnOnFunctionType();
9666 }
9667 }
9668 if (typeof newChild === 'undefined') {
9669 // If the new child is undefined, and the return fiber is a composite
9670 // component, throw an error. If Fiber return types are disabled,
9671 // we already threw above.
9672 switch (returnFiber.tag) {
9673 case ClassComponent:
9674 {
9675 {
9676 var instance = returnFiber.stateNode;
9677 if (instance.render._isMockFunction) {
9678 // We allow auto-mocks to proceed as if they're returning null.
9679 break;

Callers 4

updateCallComponentFunction · 0.70
updatePortalComponentFunction · 0.70
moveCallToHandlerPhaseFunction · 0.70

Calls 11

placeSingleChildFunction · 0.70
reconcileSingleElementFunction · 0.70
reconcileSinglePortalFunction · 0.70
reconcileSingleTextNodeFunction · 0.70
reconcileChildrenArrayFunction · 0.70
getIteratorFnFunction · 0.70
throwOnInvalidObjectTypeFunction · 0.70
warnOnFunctionTypeFunction · 0.70
invariantFunction · 0.70
deleteRemainingChildrenFunction · 0.70

Tested by

no test coverage detected