MCPcopy Create free account
hub / github.com/microsoft/SandDance / getNearestMountedFiber

Function getNearestMountedFiber

docs/external/js/react-dom.development.js:2981–3017  ·  view source on GitHub ↗
(fiber)

Source from the content-addressed store, hash-verified

2979
2980 var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
2981 function getNearestMountedFiber(fiber) {
2982 var node = fiber;
2983 var nearestMounted = fiber;
2984
2985 if (!fiber.alternate) {
2986 // If there is no alternate, this might be a new tree that isn't inserted
2987 // yet. If it is, then it will have a pending insertion effect on it.
2988 var nextNode = node;
2989
2990 do {
2991 node = nextNode;
2992
2993 if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) {
2994 // This is an insertion or in-progress hydration. The nearest possible
2995 // mounted fiber is the parent but we need to continue to figure out
2996 // if that one is still mounted.
2997 nearestMounted = node.return;
2998 }
2999
3000 nextNode = node.return;
3001 } while (nextNode);
3002 } else {
3003 while (node.return) {
3004 node = node.return;
3005 }
3006 }
3007
3008 if (node.tag === HostRoot) {
3009 // TODO: Check if this was a nested HostRoot when used with
3010 // renderContainerIntoSubtree.
3011 return nearestMounted;
3012 } // If we didn't hit the root, that means that we're in an disconnected tree
3013 // that has been unmounted.
3014
3015
3016 return null;
3017 }
3018 function getSuspenseInstanceFromFiber(fiber) {
3019 if (fiber.tag === SuspenseComponent) {
3020 var suspenseState = fiber.memoizedState;

Callers 7

isFiberMountedFunction · 0.85
isMountedFunction · 0.85
assertIsMountedFunction · 0.85
attemptToDispatchEventFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected