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

Function getNearestMountedFiber

lib/assets/react-source/development/react.js:6553–6589  ·  view source on GitHub ↗
(fiber)

Source from the content-addressed store, hash-verified

6551
6552 var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
6553 function getNearestMountedFiber(fiber) {
6554 var node = fiber;
6555 var nearestMounted = fiber;
6556
6557 if (!fiber.alternate) {
6558 // If there is no alternate, this might be a new tree that isn't inserted
6559 // yet. If it is, then it will have a pending insertion effect on it.
6560 var nextNode = node;
6561
6562 do {
6563 node = nextNode;
6564
6565 if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) {
6566 // This is an insertion or in-progress hydration. The nearest possible
6567 // mounted fiber is the parent but we need to continue to figure out
6568 // if that one is still mounted.
6569 nearestMounted = node.return;
6570 }
6571
6572 nextNode = node.return;
6573 } while (nextNode);
6574 } else {
6575 while (node.return) {
6576 node = node.return;
6577 }
6578 }
6579
6580 if (node.tag === HostRoot) {
6581 // TODO: Check if this was a nested HostRoot when used with
6582 // renderContainerIntoSubtree.
6583 return nearestMounted;
6584 } // If we didn't hit the root, that means that we're in an disconnected tree
6585 // that has been unmounted.
6586
6587
6588 return null;
6589 }
6590 function getSuspenseInstanceFromFiber(fiber) {
6591 if (fiber.tag === SuspenseComponent) {
6592 var suspenseState = fiber.memoizedState;

Callers 7

isFiberMountedFunction · 0.85
isMountedFunction · 0.85
assertIsMountedFunction · 0.85
attemptToDispatchEventFunction · 0.85
react.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected