MCPcopy
hub / github.com/facebook/react / collectScopedNodes

Function collectScopedNodes

packages/react-reconciler/src/ReactFiberScope.js:33–58  ·  view source on GitHub ↗
(
  node: Fiber,
  fn: ReactScopeQuery,
  scopedNodes: Array<any>,
)

Source from the content-addressed store, hash-verified

31const emptyObject = {};
32
33function collectScopedNodes(
34 node: Fiber,
35 fn: ReactScopeQuery,
36 scopedNodes: Array<any>,
37): void {
38 if (enableScopeAPI) {
39 if (node.tag === HostComponent) {
40 const {type, memoizedProps, stateNode} = node;
41 const instance = getPublicInstance(stateNode);
42 if (
43 instance !== null &&
44 fn(type, memoizedProps || emptyObject, instance) === true
45 ) {
46 scopedNodes.push(instance);
47 }
48 }
49 let child = node.child;
50
51 if (isFiberSuspenseAndTimedOut(node)) {
52 child = getSuspenseFallbackChild(node);
53 }
54 if (child !== null) {
55 collectScopedNodesFromChildren(child, fn, scopedNodes);
56 }
57 }
58}
59
60function collectFirstScopedNode(
61 node: Fiber,

Callers 1

Calls 6

getPublicInstanceFunction · 0.90
getSuspenseFallbackChildFunction · 0.85
pushMethod · 0.65
fnFunction · 0.50

Tested by

no test coverage detected