Skip to content

Instantly share code, notes, and snippets.

@jamesslock
Last active August 29, 2015 14:17
Show Gist options
  • Save jamesslock/767b36b2760a2e409d9d to your computer and use it in GitHub Desktop.
Save jamesslock/767b36b2760a2e409d9d to your computer and use it in GitHub Desktop.
Simple React Button Component
var React = require('react'),
Classable = require('../mixins/classable.jsx');
var Button = React.createClass({
mixins: [Classable],
buildAriaLabel: function() {
return "" + this.props.ariaLabel;
},
render: function() {
var classes = this.getClasses('btn');
var buttonProps = {
className: classes
};
if (this.props.buttonType === "link") {
return (
<a {...buttonProps} aria-label={this.buildAriaLabel()}>
{this.props.children}
</a>
)
}
else {
return (
<button {...buttonProps} aria-label={this.buildAriaLabel()}>
{this.props.children}
</button>
)
}
}
});
module.exports = Button;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment