Created
November 19, 2015 07:18
-
-
Save heyjohnmurray/41a77c7e1a39b3d1da70 to your computer and use it in GitHub Desktop.
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
// You can attach elment attributes to your app and read them in your rendered UI | |
React.render(<App text="this is a text value. wow!" />, document.body); | |
// 'text' in this example can now be passed from your app logic to your rendered UI view. | |
// basic properties instance | |
var App = React.createClass({ | |
render: function() { | |
var text = this.props.text; | |
return ( | |
<h1>{text}</h1> | |
); | |
} | |
}); | |
// passing properties through an object | |
var App = React.createClass({ | |
propTypes: { | |
text: React.PropTypes.string // requiring this value to be a string. if not, it casues an error | |
// text: React.PropTypes.string.isRequired // adding .isRequired does just that and could be good for validation | |
}, | |
render: function() { | |
var text = this.props.text; | |
return ( | |
<h1>{text}</h1> | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment