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

Function collectFirstScopedNode

packages/react-reconciler/src/ReactFiberScope.js:60–82  ·  view source on GitHub ↗
(
  node: Fiber,
  fn: ReactScopeQuery,
)

Source from the content-addressed store, hash-verified

58}
59
60function collectFirstScopedNode(
61 node: Fiber,
62 fn: ReactScopeQuery,
63): null | Object {
64 if (enableScopeAPI) {
65 if (node.tag === HostComponent) {
66 const {type, memoizedProps, stateNode} = node;
67 const instance = getPublicInstance(stateNode);
68 if (instance !== null && fn(type, memoizedProps, instance) === true) {
69 return instance;
70 }
71 }
72 let child = node.child;
73
74 if (isFiberSuspenseAndTimedOut(node)) {
75 child = getSuspenseFallbackChild(node);
76 }
77 if (child !== null) {
78 return collectFirstScopedNodeFromChildren(child, fn);
79 }
80 }
81 return null;
82}
83
84function collectScopedNodesFromChildren(
85 startingChild: Fiber,

Callers 1

Calls 5

getPublicInstanceFunction · 0.90
getSuspenseFallbackChildFunction · 0.85
fnFunction · 0.50

Tested by

no test coverage detected