Last active
December 19, 2015 16:39
-
-
Save RyanAtViceSoftware/e0433c720758ca22fec0 to your computer and use it in GitHub Desktop.
Hello React - props - how to pass default prop values. JsFiddle: http://jsfiddle.net/gh/gist/library/pure/e0433c720758ca22fec0/
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
<script src="https://fb.me/react-with-addons-0.14.0.js"></script> | |
<script src="https://fb.me/react-dom-0.14.0.js"></script> | |
<div id="view"/> |
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 HelloReact = React.createClass({ | |
getDefaultProps: function() { | |
return { | |
message: 'I am from default' | |
}; | |
}, | |
render: function() { | |
return ( | |
<div> | |
<div>Hello React</div> | |
<div>{this.props.message}</div> | |
</div> | |
); | |
} | |
}); | |
ReactDOM.render( | |
<HelloReact />, | |
document.getElementById('view')); |
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
name: ReactJs example by Ryan Vice - www.ViceSoftware.com | |
description: Hello React - props - how to pass default prop values. | |
authors: | |
- Ryan Vice | |
resources: | |
normalize_css: no | |
wrap: h | |
panel_js: 3 | |
panel_css: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment