(children, callback)
| 6 | } |
| 7 | |
| 8 | export function deepMap(children, callback) { |
| 9 | return Children.map(children, (child) => { |
| 10 | // null happens when conditionally rendering TabPanel/Tab |
| 11 | // see https://github.com/reactjs/react-tabs/issues/37 |
| 12 | if (child === null) return null; |
| 13 | |
| 14 | if (isTabChild(child)) { |
| 15 | return callback(child); |
| 16 | } |
| 17 | |
| 18 | if ( |
| 19 | child.props && |
| 20 | child.props.children && |
| 21 | typeof child.props.children === 'object' |
| 22 | ) { |
| 23 | // Clone the child that has children and map them too |
| 24 | return cloneElement(child, { |
| 25 | ...child.props, |
| 26 | children: deepMap(child.props.children, callback), |
| 27 | }); |
| 28 | } |
| 29 | |
| 30 | return child; |
| 31 | }); |
| 32 | } |
| 33 | |
| 34 | export function deepForEach(children, callback) { |
| 35 | return Children.forEach(children, (child) => { |
no test coverage detected
searching dependent graphs…