I am using react, and I am trying to pass props/context to my dynamic childrens, by dymamic childrens I mean childrens are render using
{this.props.children}
How can I pass to this children (In my code I know it's type) context/props?
In this jsbin there is an example that it dosen't work on dynamic childrens. http://jsbin.com/puhilabike/1/edit?html,js,output
Though @WiredPrairie's answer is correct, the React.addons.cloneWithProps
is deprecated as of React v0.13RC. The updated way to do this is to use React.cloneElement
. An example:
renderedChildren = React.Children.map(this.props.children, function (child) {
return React.cloneElement(child, { parentValue: self.props.parentValue });
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With