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

Function reconcileSinglePortal

packages/react-reconciler/src/ReactChildFiber.js:1728–1762  ·  view source on GitHub ↗
(
    returnFiber: Fiber,
    currentFirstChild: Fiber | null,
    portal: ReactPortal,
    lanes: Lanes,
  )

Source from the content-addressed store, hash-verified

1726 }
1727
1728 function reconcileSinglePortal(
1729 returnFiber: Fiber,
1730 currentFirstChild: Fiber | null,
1731 portal: ReactPortal,
1732 lanes: Lanes,
1733 ): Fiber {
1734 const key = portal.key;
1735 let child = currentFirstChild;
1736 while (child !== null) {
1737 // TODO: If key === null and child.key === null, then this only applies to
1738 // the first item in the list.
1739 if (child.key === key) {
1740 if (
1741 child.tag === HostPortal &&
1742 child.stateNode.containerInfo === portal.containerInfo &&
1743 child.stateNode.implementation === portal.implementation
1744 ) {
1745 deleteRemainingChildren(returnFiber, child.sibling);
1746 const existing = useFiber(child, portal.children || []);
1747 existing.return = returnFiber;
1748 return existing;
1749 } else {
1750 deleteRemainingChildren(returnFiber, child);
1751 break;
1752 }
1753 } else {
1754 deleteChild(returnFiber, child);
1755 }
1756 child = child.sibling;
1757 }
1758
1759 const created = createFiberFromPortal(portal, returnFiber.mode, lanes);
1760 created.return = returnFiber;
1761 return created;
1762 }
1763
1764 // This API will tag the children with the side-effect of the reconciliation
1765 // itself. They will be added to the side-effect list as we pass through the

Callers 1

reconcileChildFibersImplFunction · 0.85

Calls 4

createFiberFromPortalFunction · 0.90
deleteRemainingChildrenFunction · 0.85
useFiberFunction · 0.85
deleteChildFunction · 0.85

Tested by

no test coverage detected