Skip to content

Instantly share code, notes, and snippets.

@anthonylebrun
Created February 7, 2016 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonylebrun/d375024ba5fb3261f683 to your computer and use it in GitHub Desktop.
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.
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