Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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