MCPcopy Create free account
hub / github.com/danielstocks/react-sortable / unmountHostComponents

Function unmountHostComponents

bundle.js:7574–7586  ·  view source on GitHub ↗
(current)

Source from the content-addressed store, hash-verified

7572var node=root;while(true){commitUnmount(node);// Visit children because they may contain more composite or host nodes.
7573// Skip portals because commitUnmount() currently visits them recursively.
7574if(node.child!==null&&node.tag!==HostPortal$7){node.child['return']=node;node=node.child;continue;}if(node===root){return;}while(node.sibling===null){if(node['return']===null||node['return']===root){return;}node=node['return'];}node.sibling['return']=node['return'];node=node.sibling;}}function unmountHostComponents(current){// We only have the top Fiber that was inserted but we need recurse down its
7575var node=current;// Each iteration, currentParent is populated with node's host parent if not
7576// currentParentIsValid.
7577var currentParentIsValid=false;var currentParent=void 0;var currentParentIsContainer=void 0;while(true){if(!currentParentIsValid){var parent=node['return'];findParent:while(true){!(parent!==null)?invariant(false,'Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.'):void 0;switch(parent.tag){case HostComponent$9:currentParent=parent.stateNode;currentParentIsContainer=false;break findParent;case HostRoot$9:currentParent=parent.stateNode.containerInfo;currentParentIsContainer=true;break findParent;case HostPortal$7:currentParent=parent.stateNode.containerInfo;currentParentIsContainer=true;break findParent;}parent=parent['return'];}currentParentIsValid=true;}if(node.tag===HostComponent$9||node.tag===HostText$7){commitNestedUnmounts(node);// After all the children have unmounted, it is now safe to remove the
7578// node from the tree.
7579if(currentParentIsContainer){removeChildFromContainer(currentParent,node.stateNode);}else{removeChild(currentParent,node.stateNode);}// Don't visit children because we already visited them.
7580}else if(node.tag===HostPortal$7){// When we go into a portal, it becomes the parent to remove from.
7581// We will reassign it back when we pop the portal on the way up.
7582currentParent=node.stateNode.containerInfo;// Visit children because portals might contain host components.
7583if(node.child!==null){node.child['return']=node;node=node.child;continue;}}else{commitUnmount(node);// Visit children because we may find more host components below.
7584if(node.child!==null){node.child['return']=node;node=node.child;continue;}}if(node===current){return;}while(node.sibling===null){if(node['return']===null||node['return']===current){return;}node=node['return'];if(node.tag===HostPortal$7){// When we go out of the portal, we need to restore the parent.
7585// Since we don't keep a stack of them, we will search for it.
7586currentParentIsValid=false;}}node.sibling['return']=node['return'];node=node.sibling;}}function commitDeletion(current){// Recursively delete all host nodes from the parent.
7587// Detach refs and call componentWillUnmount() on the whole subtree.
7588unmountHostComponents(current);// Cut off the return pointers to disconnect it from the tree. Ideally, we
7589// should clear the child pointer of the parent alternate to let this

Callers 2

commitDeletionFunction · 0.85
commitUnmountFunction · 0.85

Calls 3

commitNestedUnmountsFunction · 0.85
commitUnmountFunction · 0.85
invariantFunction · 0.70

Tested by

no test coverage detected