Skip to content

Instantly share code, notes, and snippets.

@heyjohnmurray
Created November 23, 2015 03:44
Show Gist options
  • Save heyjohnmurray/343b1b9dbe36d187a579 to your computer and use it in GitHub Desktop.
Save heyjohnmurray/343b1b9dbe36d187a579 to your computer and use it in GitHub Desktop.
Sample code showing how composable components look similar to OOP JS
var BaseButton = React.createClass({
propTypes: {
buttonText: React.PropTypes.string.isRequired,
buttonColor: React.PropTypes.string,
buttonHoverColor: React.PropTypes.string,
useSpinner: React.PropTypes.bool,
buttonHoverTextColor: React.PropTypes.string,
buttonLink: React.PropTypes.string
},
linkToLocation: function(evt) {
document.location.href = this.props.buttonLink;
evt.preventDefault();
},
spinnerIfSpecified: function() {
if (this.props.useSpinner === true) {
return <img src="/images/transparent-spinner.gif" alt="" />;
}
},
...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment