Skip to content

Instantly share code, notes, and snippets.

Last active October 29, 2015 04:02
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
// yell at any developers using `this.props.whatever` if PropTypes.whatever is not set
let PropCheckMixin = {
componentWillMount() {
componentWillReceiveProps(nextProps) {
validateProps(props) {
let { displayName, propTypes } = this.constructor
for (let prop in props) {
if (!propTypes[prop]) {
console.warn(`You set a property "${prop}" on Component "${displayName}" but did not provide a PropType declaration for this prop.`)
module.exports = PropCheckMixin
Copy link

this seems helpful, refer

Copy link

gajus commented Aug 30, 2015

I have developed a higher order component that does this.

It is more or less the same as this mixin. The source code is written in ES6 and uses ES6 classes. It also adds support for HTML properties using allowHTMLProps option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment