Skip to content

Instantly share code, notes, and snippets.

@heyjohnmurray
Created November 22, 2015 06:28
Show Gist options
  • Save heyjohnmurray/0ad985243d2d21300563 to your computer and use it in GitHub Desktop.
Save heyjohnmurray/0ad985243d2d21300563 to your computer and use it in GitHub Desktop.
In React you can access the inner HTML or the value of a nested component using this.props.children
var App = React.createClass({
render: function() {
// notice that we have the "Button" and "Heart" components
return <Button>I <Heart /> React</Button>
}
});
var Button = React.createClass({
render: function() {
// notice that this.props.children gave us the value of both the "Button" and the "Heart" component
return <button>{this.props.children}</button>
}
});
var Heart = React.createClass({
render: function(){
return <span class="heart">Heart</span>
}
});
@MacaylaMarvelous81
Copy link

Wow I was looking for if something like this is possible in React!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment