Skip to content

Instantly share code, notes, and snippets.

@kasprownik
Last active February 3, 2016 11:53
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/2768859ef3b724754586 to your computer and use it in GitHub Desktop.
Save kasprownik/2768859ef3b724754586 to your computer and use it in GitHub Desktop.
// src/components/Text.js
import React, { PropTypes } from 'react';
import TextField from 'material-ui/lib/text-field';
import * as validators from '../validators';
export default React.createClass({
//...
contextTypes: {
update: PropTypes.func.isRequired,
values: PropTypes.object.isRequired,
registerValidation: PropTypes.func.isRequired
},
componentWillMount() {
this.removeValidationFromContext = this.context.registerValidation(show =>
this.isValid(show));
},
componentWillUnmount() {
this.removeValidationFromContext();
},
//...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment