Created
November 23, 2015 03:44
-
-
Save heyjohnmurray/343b1b9dbe36d187a579 to your computer and use it in GitHub Desktop.
Sample code showing how composable components look similar to OOP JS
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 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