Created
February 7, 2016 20:16
-
-
Save anthonylebrun/d375024ba5fb3261f683 to your computer and use it in GitHub Desktop.
Dynamically passing props in react from a component to it's yet unknown children.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var FooBar = React.createClass({ | |
render() { | |
return <div className="foo-bar"> | |
{React.Children.map(this.props.children, child => React.cloneElement(child, {passedProp: this.props.passedProp}))} | |
</div> | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment