react passing props to this.props.children

Previous article I mentioned about this.props.children and its feature, problem is this.props.children does not not provide a way to pass down the props, so we need a wrapper called React.cloneElement which allows you get this component and return a new component where you can also pass in the props like this:

{React.cloneElement(this.props.children, this.props)}

by the way there are more very useful helpers to help you interacting with this.props.children, for example:

React.children.map(this.props.children,()=>{…})

React.Children.forEach(this.props.children, (child, i) => {
  console.log(child + ' at index: ' + i);
})

see all API at React.children