MCPcopy Index your code
hub / github.com/krasimir/react-in-patterns / reconcileChildrenIterator

Function reconcileChildrenIterator

code/composition/public/app.js:9527–9670  ·  view source on GitHub ↗
(returnFiber, currentFirstChild, newChildrenIterable, expirationTime)

Source from the content-addressed store, hash-verified

9525 }
9526
9527 function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {
9528 // This is the same implementation as reconcileChildrenArray(),
9529 // but using the iterator instead.
9530
9531 var iteratorFn = getIteratorFn(newChildrenIterable);
9532 !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;
9533
9534 {
9535 // Warn about using Maps as children
9536 if (typeof newChildrenIterable.entries === 'function') {
9537 var possibleMap = newChildrenIterable;
9538 if (possibleMap.entries === iteratorFn) {
9539 warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$2());
9540 didWarnAboutMaps = true;
9541 }
9542 }
9543
9544 // First, validate keys.
9545 // We'll get a different iterator later for the main pass.
9546 var _newChildren = iteratorFn.call(newChildrenIterable);
9547 if (_newChildren) {
9548 var knownKeys = null;
9549 var _step = _newChildren.next();
9550 for (; !_step.done; _step = _newChildren.next()) {
9551 var child = _step.value;
9552 knownKeys = warnOnInvalidKey(child, knownKeys);
9553 }
9554 }
9555 }
9556
9557 var newChildren = iteratorFn.call(newChildrenIterable);
9558 !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;
9559
9560 var resultingFirstChild = null;
9561 var previousNewFiber = null;
9562
9563 var oldFiber = currentFirstChild;
9564 var lastPlacedIndex = 0;
9565 var newIdx = 0;
9566 var nextOldFiber = null;
9567
9568 var step = newChildren.next();
9569 for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
9570 if (oldFiber.index > newIdx) {
9571 nextOldFiber = oldFiber;
9572 oldFiber = null;
9573 } else {
9574 nextOldFiber = oldFiber.sibling;
9575 }
9576 var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);
9577 if (newFiber === null) {
9578 // TODO: This breaks on empty slots like null children. That's
9579 // unfortunate because it triggers the slow path all the time. We need
9580 // a better way to communicate whether this was a miss or null,
9581 // boolean, undefined, etc.
9582 if (!oldFiber) {
9583 oldFiber = nextOldFiber;
9584 }

Callers 1

reconcileChildFibersFunction · 0.70

Calls 11

warningFunction · 0.85
getIteratorFnFunction · 0.70
invariantFunction · 0.70
warnOnInvalidKeyFunction · 0.70
updateSlotFunction · 0.70
deleteChildFunction · 0.70
placeChildFunction · 0.70
deleteRemainingChildrenFunction · 0.70
createChildFunction · 0.70
mapRemainingChildrenFunction · 0.70
updateFromMapFunction · 0.70

Tested by

no test coverage detected