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

Function reconcileChildrenIterator

code/third-party/public/app.js:8622–8765  ·  view source on GitHub ↗
(returnFiber, currentFirstChild, newChildrenIterable, expirationTime)

Source from the content-addressed store, hash-verified

8620 }
8621
8622 function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {
8623 // This is the same implementation as reconcileChildrenArray(),
8624 // but using the iterator instead.
8625
8626 var iteratorFn = getIteratorFn(newChildrenIterable);
8627 !(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;
8628
8629 {
8630 // Warn about using Maps as children
8631 if (typeof newChildrenIterable.entries === 'function') {
8632 var possibleMap = newChildrenIterable;
8633 if (possibleMap.entries === iteratorFn) {
8634 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());
8635 didWarnAboutMaps = true;
8636 }
8637 }
8638
8639 // First, validate keys.
8640 // We'll get a different iterator later for the main pass.
8641 var _newChildren = iteratorFn.call(newChildrenIterable);
8642 if (_newChildren) {
8643 var knownKeys = null;
8644 var _step = _newChildren.next();
8645 for (; !_step.done; _step = _newChildren.next()) {
8646 var child = _step.value;
8647 knownKeys = warnOnInvalidKey(child, knownKeys);
8648 }
8649 }
8650 }
8651
8652 var newChildren = iteratorFn.call(newChildrenIterable);
8653 !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;
8654
8655 var resultingFirstChild = null;
8656 var previousNewFiber = null;
8657
8658 var oldFiber = currentFirstChild;
8659 var lastPlacedIndex = 0;
8660 var newIdx = 0;
8661 var nextOldFiber = null;
8662
8663 var step = newChildren.next();
8664 for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
8665 if (oldFiber.index > newIdx) {
8666 nextOldFiber = oldFiber;
8667 oldFiber = null;
8668 } else {
8669 nextOldFiber = oldFiber.sibling;
8670 }
8671 var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);
8672 if (newFiber === null) {
8673 // TODO: This breaks on empty slots like null children. That's
8674 // unfortunate because it triggers the slow path all the time. We need
8675 // a better way to communicate whether this was a miss or null,
8676 // boolean, undefined, etc.
8677 if (!oldFiber) {
8678 oldFiber = nextOldFiber;
8679 }

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