Skip to content

Instantly share code, notes, and snippets.

@liammclennan
Created March 9, 2014 22:10
Show Gist options
  • Save liammclennan/9455524 to your computer and use it in GitHub Desktop.
Save liammclennan/9455524 to your computer and use it in GitHub Desktop.
React mixin that warns if a propTypes key is missing
define('validation', [], function() {
return {
allPropsSpecifiedMixing: {
componentDidMount: function() {
var unspecifiedPropKeys = _.difference(
_.keys(this.props),
_.keys(this.type.propTypes || {}).concat('ref'));
if (unspecifiedPropKeys.length) {
console.warn('Component ' +
(this.type.displayName || '?') +
' missing propType values for: ' +
JSON.stringify(unspecifiedPropKeys));
}
}
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment