Skip to content

Instantly share code, notes, and snippets.

@kasprownik
Last active January 29, 2016 17:01
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 kasprownik/a879ac3ab4a28e5fcc4c to your computer and use it in GitHub Desktop.
Save kasprownik/a879ac3ab4a28e5fcc4c to your computer and use it in GitHub Desktop.
// src/components/SubmitButton.js
import React, { PropTypes } from 'react';
import RaisedButton from 'material-ui/lib/raised-button';
export default React.createClass({
displayName: 'SubmitButton',
propTypes: {
label: PropTypes.string
},
contextTypes: {
isFormValid: PropTypes.func.isRequired,
submit: PropTypes.func.isRequired
},
getDefaultProps() {
return {
label: 'Submit'
};
},
render() {
return (
<div>
<RaisedButton
primary
disabled={!this.context.isFormValid()}
label={this.props.label}
onTouchTap={this.context.submit}/>
</div>
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment