shallowly
Version:
Shallowly: Modern shallow renderer for React 18+. Enzyme-compatible API, 2x faster, with TypeScript support.
12 lines (11 loc) • 670 B
TypeScript
/**
* Traverses the React element tree depth-first and pushes to `results` all
* nodes that match the selector.
*
* @param {React.ReactNode} node - Current node.
* @param {string|Function} selector - Selector string or component.
* @param {Array<React.ReactNode>} results - Collected matching nodes.
* @param {(node: React.ReactNode, selector: string|Function) => boolean} matchesSelector - Function that decides if a node matches.
*/
export function findNodes(node: React.ReactNode, selector: string | Function, results: Array<React.ReactNode>, matchesSelector: (node: React.ReactNode, selector: string | Function) => boolean): void;
import React from 'react';