APIs
Children.map
Applies a callback to each traversed child. It does not descend into the rendered output of elements. Prefer mapping explicit data arrays for ordinary lists.
Formal Syntax & Structure
react syntaxreact
Children.map(children, fn)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| children | React children | Opaque children value. |
| fn | function | Receives a child and its index. |
Return Value
array | null | undefined
Mapped child structure; null or undefined input is returned as-is.
Working Example
Example Snippetreact
import { Children } from 'react';console.log(Children.map(['A', 'B'], (child) => child + '!'));