MCPcopy
hub / github.com/react-bootstrap/react-bootstrap / map

Function map

src/ElementChildren.tsx:11–20  ·  view source on GitHub ↗

* 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,
)

Source from the content-addressed store, hash-verified

9 *
10 */
11function 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".

Callers 4

TabsFunction · 0.90
ProgressBar.tsxFile · 0.90
Carousel.tsxFile · 0.90

Calls 1

funcFunction · 0.85

Tested by

no test coverage detected