MCPcopy
hub / github.com/reactjs/react-tabs / deepMap

Function deepMap

src/helpers/childrenDeepMap.js:8–32  ·  view source on GitHub ↗
(children, callback)

Source from the content-addressed store, hash-verified

6}
7
8export 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
34export function deepForEach(children, callback) {
35 return Children.forEach(children, (child) => {

Callers 1

getChildrenFunction · 0.90

Calls 1

isTabChildFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…