Detecting the type of Children components

suggest change

Sometimes it’s really useful to know the type of child component when iterating through them. In order to iterate through the children components you can use React Children.map util function:

React.Children.map(this.props.children, (child) => {
  if (child.type === MyComponentType) {
    ...
  }
});

The child object exposes the type property which you can compare to a specific component.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Props in react:
*Detecting the type of Children components

Table Of Contents