Skip to content

Instantly share code, notes, and snippets.

@hackjoy
Last active November 11, 2015 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hackjoy/ee9ac4ec57d5bf93cec3 to your computer and use it in GitHub Desktop.
Save hackjoy/ee9ac4ec57d5bf93cec3 to your computer and use it in GitHub Desktop.
React Example
import React from 'react';
export default React.createClass({
displayName: 'Button',
propTypes: {
text: React.PropTypes.string.isRequired,
isDisabled: React.PropTypes.bool
},
getDefaultProps() {
return {
icon: 'icon-chevron_down',
isDisabled: true
};
},
getInitialState() {
return {
isOpen: this.props.isOpen
};
},
toggle(ev) { this.setState({isOpen: ev.target.checked}); },
render() {
return (
<button className='button'>{this.props.text}</button>
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment