Skip to content

Instantly share code, notes, and snippets.

@nickdima
Created July 13, 2015 20:28
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 nickdima/f38e4b8b2617f03bee5a to your computer and use it in GitHub Desktop.
Save nickdima/f38e4b8b2617f03bee5a to your computer and use it in GitHub Desktop.
Component Definition
class Component extends React.Component
@propTypes:
name: React.PropTypes.string
@defaultProps:
name: 'Nick'
state:
disabled: false
greet: =>
alert 'Hello ' + @props.name
@setState disabled: true
render: ->
<button disabled={@state.enabled} onClick={@greet}>Click Me!</button>
class Component extends React.Component {
constructor(props) {
super(props);
this.state = {disabled: false};
}
greet() {
alert('Hello ' + this.props.name);
this.setState({disabled: true});
}
render() {
return (
<button disabled={this.state.disabled} onClick={this.greet.bind(this)}>Click Me!</button>
);
}
}
Component.propTypes = {
name: React.PropTypes.string
};
Component.defaultProps = { name: 'Nick' };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment