React.Children

React.Children

React.Children provides utilities for dealing with the this.props.children opaque data structure.

React.Children.map

1
array React.Children.map(object children, function fn [, object thisArg])

Invoke fn on every immediate child contained within children with this set to thisArg. If children is a keyed fragment or array it will be traversed: fn will never be passed the container objects. If children is null or undefined returns null or undefined rather than an array.

React.Children.forEach

1
React.Children.forEach(object children, function fn [, object thisArg])

Like React.Children.map() but does not return an array.

React.Children.count

1
number React.Children.count(object children)

Return the total number of components in children, equal to the number of times that a callback passed to map or forEach would be invoked.

React.Children.only

1
object React.Children.only(object children)

Return the only child in children. Throws otherwise.

React.Children.toArray

1
array React.Children.toArray(object children)

Return the children opaque data structure as a flat array with keys assigned to each child. Useful if you want to manipulate collections of children in your render methods, especially if you want to reorder or slice this.props.children before passing it down.

doc_React
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.