React.js

React Hackin Solution – Passing variables and methods to props.children

We can pass variables and methods to props.children following way.

React.Children.map(children, child =>

React.cloneElement(child, {

method: methodName

}

)

This is useful when we need to pass variables and methods to react components which is embeded from props.children.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *