MCPcopy
hub / github.com/facebook/react / reconcileChildFibersImpl

Function reconcileChildFibersImpl

packages/react-reconciler/src/ReactChildFiber.js:1767–1944  ·  view source on GitHub ↗
(
    returnFiber: Fiber,
    currentFirstChild: Fiber | null,
    newChild: any,
    lanes: Lanes,
  )

Source from the content-addressed store, hash-verified

1765 // itself. They will be added to the side-effect list as we pass through the
1766 // children and the parent.
1767 function reconcileChildFibersImpl(
1768 returnFiber: Fiber,
1769 currentFirstChild: Fiber | null,
1770 newChild: any,
1771 lanes: Lanes,
1772 ): Fiber | null {
1773 // This function is only recursive for Usables/Lazy and not nested arrays.
1774 // That's so that using a Lazy wrapper is unobservable to the Fragment
1775 // convention.
1776 // If the top level item is an array, we treat it as a set of children,
1777 // not as a fragment. Nested arrays on the other hand will be treated as
1778 // fragment nodes. Recursion happens at the normal flow.
1779
1780 // Handle top level unkeyed fragments without refs (enableFragmentRefs)
1781 // as if they were arrays. This leads to an ambiguity between <>{[...]}</> and <>...</>.
1782 // We treat the ambiguous cases above the same.
1783 // We don't use recursion here because a fragment inside a fragment
1784 // is no longer considered "top level" for these purposes.
1785 const isUnkeyedUnrefedTopLevelFragment =
1786 typeof newChild === 'object' &&
1787 newChild !== null &&
1788 newChild.type === REACT_FRAGMENT_TYPE &&
1789 newChild.key === null &&
1790 (enableFragmentRefs ? newChild.props.ref === undefined : true);
1791
1792 if (isUnkeyedUnrefedTopLevelFragment) {
1793 validateFragmentProps(newChild, null, returnFiber);
1794 newChild = newChild.props.children;
1795 }
1796
1797 // Handle object types
1798 if (typeof newChild === 'object' && newChild !== null) {
1799 switch (newChild.$$typeof) {
1800 case REACT_ELEMENT_TYPE: {
1801 const prevDebugInfo = pushDebugInfo(newChild._debugInfo);
1802 const firstChild = placeSingleChild(
1803 reconcileSingleElement(
1804 returnFiber,
1805 currentFirstChild,
1806 newChild,
1807 lanes,
1808 ),
1809 );
1810 currentDebugInfo = prevDebugInfo;
1811 return firstChild;
1812 }
1813 case REACT_PORTAL_TYPE:
1814 return placeSingleChild(
1815 reconcileSinglePortal(
1816 returnFiber,
1817 currentFirstChild,
1818 newChild,
1819 lanes,
1820 ),
1821 );
1822 case REACT_LAZY_TYPE: {
1823 const prevDebugInfo = pushDebugInfo(newChild._debugInfo);
1824 const result = resolveLazy((newChild: any));

Callers 1

reconcileChildFibersFunction · 0.85

Calls 15

resolveLazyFunction · 0.90
pushDebugInfoFunction · 0.85
placeSingleChildFunction · 0.85
reconcileSingleElementFunction · 0.85
reconcileSinglePortalFunction · 0.85
isArrayFunction · 0.85
reconcileChildrenArrayFunction · 0.85
throwOnInvalidObjectTypeFunction · 0.85
reconcileSingleTextNodeFunction · 0.85

Tested by

no test coverage detected