* Iterates through children that are typically specified as `props.children`, * but only maps over children that are "valid elements". * * The mapFunction provided index will be normalised to the components mapped, * so an invalid component would not increase the index. *
( children, func: (el: React.ReactElement<P>, index: number) => any, )
| 9 | * |
| 10 | */ |
| 11 | function map<P = any>( |
| 12 | children, |
| 13 | func: (el: React.ReactElement<P>, index: number) => any, |
| 14 | ) { |
| 15 | let index = 0; |
| 16 | |
| 17 | return React.Children.map(children, (child) => |
| 18 | React.isValidElement<P>(child) ? func(child, index++) : child, |
| 19 | ); |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Iterates through children that are "valid elements". |
no test coverage detected