How to pass props to {this.props.children}

Posted by Pinki | Updated on

If you want to pass props to {this.props.children} You can use React.Children to iterate over the children, and then clone each element with new props (shallow merged) using React.cloneElement.

Calling children as a function

You can also pass props to children with render props. In this approach the children (which can be children or any other prop name) is a function which can accept any arguments you want to pass and returns the children:

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@] Your question and answer will appear on and help other developers.

Related Questions & Answers