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

NameTypeDescription
childrenReact childrenOpaque children value.
fnfunctionReceives 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 + '!'));
React Reference