F

findInTree

Finds the first node in a React element or fiber tree a predicate matches, searching only downward. Start from an element, a fiber, or a class instance's _reactInternals.

function findInTree<T = any>(root: any, predicate: TreePredicate, options?: TreeSearchOptions): T | undefined

Parameters

NameTypeDescription
rootany

The element or fiber to start from; it is tested too.

predicateTreePredicate

Tests each non-nullish node.

options?TreeSearchOptions

walkable adds keys to the React ones (such as return), ignore skips keys, maxDepth defaults to 100.

Returns

T | undefined

The first match, or undefined when none matches.