MCPcopy
hub / github.com/react/react / getNearestFiber

Function getNearestFiber

packages/react-devtools-shared/src/backend/fiber/renderer.js:7687–7704  ·  view source on GitHub ↗
(devtoolsInstance: DevToolsInstance)

Source from the content-addressed store, hash-verified

7685 }
7686
7687 function getNearestFiber(devtoolsInstance: DevToolsInstance): null | Fiber {
7688 if (devtoolsInstance.kind === VIRTUAL_INSTANCE) {
7689 let inst: DevToolsInstance = devtoolsInstance;
7690 while (inst.kind === VIRTUAL_INSTANCE) {
7691 // For virtual instances, we search deeper until we find a Fiber instance.
7692 // Then we search upwards from that Fiber. That's because Virtual Instances
7693 // will always have an Fiber child filtered or not. If we searched its parents
7694 // we might skip through a filtered Error Boundary before we hit a FiberInstance.
7695 if (inst.firstChild === null) {
7696 return null;
7697 }
7698 inst = inst.firstChild;
7699 }
7700 return inst.data.return;
7701 } else {
7702 return devtoolsInstance.data;
7703 }
7704 }
7705
7706 // React will switch between these implementations depending on whether
7707 // we have any manually suspended/errored-out Fibers or not.

Callers 3

overrideErrorFunction · 0.85
overrideSuspenseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected