* Iterates through children that are "valid elements". * * The provided forEachFunc(child, index) will be called for each * leaf child with the index reflecting the position relative to "valid components".
( children, func: (el: React.ReactElement<P>, index: number) => void, )
| 26 | * leaf child with the index reflecting the position relative to "valid components". |
| 27 | */ |
| 28 | function forEach<P = any>( |
| 29 | children, |
| 30 | func: (el: React.ReactElement<P>, index: number) => void, |
| 31 | ) { |
| 32 | let index = 0; |
| 33 | React.Children.forEach(children, (child) => { |
| 34 | if (React.isValidElement<P>(child)) func(child, index++); |
| 35 | }); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Finds whether a component's `children` prop includes a React element of the |
no test coverage detected
searching dependent graphs…