MCPcopy Create free account
hub / github.com/reactjs/react-rails / unmountHostComponents

Function unmountHostComponents

lib/assets/react-source/development/react.js:24089–24189  ·  view source on GitHub ↗
(finishedRoot, current, renderPriorityLevel)

Source from the content-addressed store, hash-verified

24087 }
24088
24089 function unmountHostComponents(finishedRoot, current, renderPriorityLevel) {
24090 // We only have the top Fiber that was deleted but we need to recurse down its
24091 // children to find all the terminal nodes.
24092 var node = current; // Each iteration, currentParent is populated with node's host parent if not
24093 // currentParentIsValid.
24094
24095 var currentParentIsValid = false; // Note: these two variables *must* always be updated together.
24096
24097 var currentParent;
24098 var currentParentIsContainer;
24099
24100 while (true) {
24101 if (!currentParentIsValid) {
24102 var parent = node.return;
24103
24104 findParent: while (true) {
24105 if (!(parent !== null)) {
24106 {
24107 throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." );
24108 }
24109 }
24110
24111 var parentStateNode = parent.stateNode;
24112
24113 switch (parent.tag) {
24114 case HostComponent:
24115 currentParent = parentStateNode;
24116 currentParentIsContainer = false;
24117 break findParent;
24118
24119 case HostRoot:
24120 currentParent = parentStateNode.containerInfo;
24121 currentParentIsContainer = true;
24122 break findParent;
24123
24124 case HostPortal:
24125 currentParent = parentStateNode.containerInfo;
24126 currentParentIsContainer = true;
24127 break findParent;
24128
24129 }
24130
24131 parent = parent.return;
24132 }
24133
24134 currentParentIsValid = true;
24135 }
24136
24137 if (node.tag === HostComponent || node.tag === HostText) {
24138 commitNestedUnmounts(finishedRoot, node, renderPriorityLevel); // After all the children have unmounted, it is now safe to remove the
24139 // node from the tree.
24140
24141 if (currentParentIsContainer) {
24142 removeChildFromContainer(currentParent, node.stateNode);
24143 } else {
24144 removeChild(currentParent, node.stateNode);
24145 } // Don't visit children because we already visited them.
24146

Callers 2

commitUnmountFunction · 0.85
commitDeletionFunction · 0.85

Calls 4

commitNestedUnmountsFunction · 0.85
removeChildFromContainerFunction · 0.85
removeChildFunction · 0.85
commitUnmountFunction · 0.85

Tested by

no test coverage detected