MCPcopy Index your code
hub / github.com/react/react / findFiberRootForHostRoot

Function findFiberRootForHostRoot

packages/react-reconciler/src/ReactTestSelectors.js:120–143  ·  view source on GitHub ↗
(hostRoot: Instance)

Source from the content-addressed store, hash-verified

118}
119
120function findFiberRootForHostRoot(hostRoot: Instance): Fiber {
121 const maybeFiber = getInstanceFromNode((hostRoot: any));
122 if (maybeFiber != null) {
123 if (typeof maybeFiber.memoizedProps['data-testname'] !== 'string') {
124 throw new Error(
125 'Invalid host root specified. Should be either a React container or a node with a testname attribute.',
126 );
127 }
128
129 return ((maybeFiber: any): Fiber);
130 } else {
131 const fiberRoot = findFiberRoot(hostRoot);
132
133 if (fiberRoot === null) {
134 throw new Error(
135 'Could not find React container within specified host subtree.',
136 );
137 }
138
139 // The Flow type for FiberRoot is a little funky.
140 // createFiberRoot() cheats this by treating the root as :any and adding stateNode lazily.
141 return ((fiberRoot: any).stateNode.current: Fiber);
142 }
143}
144
145function matchSelector(fiber: Fiber, selector: Selector): boolean {
146 const tag = fiber.tag;

Callers 3

findAllNodesFunction · 0.85
focusWithinFunction · 0.85

Calls 2

getInstanceFromNodeFunction · 0.90
findFiberRootFunction · 0.90

Tested by

no test coverage detected