Created
November 22, 2015 06:28
-
-
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
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 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> | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wow I was looking for if something like this is possible in React!