APIs

Children.forEach

Calls a function for each traversed child without building an output array. Avoid side effects during rendering.

Formal Syntax & Structure

react syntaxreact
Children.forEach(children, fn)

Parameters & Attributes

NameTypeDescription
childrenReact childrenOpaque children value.
fnfunctionReceives a child and its index.

Return Value

undefined

No transformed result.

Working Example

Example Snippetreact
import { Children } from 'react';const labels = [];Children.forEach(['A', 'B'], child => labels.push(child));console.log(labels);
React Reference