ljharb / prop-types-tools

Custom React PropType validators
MIT License
671 stars 50 forks source link

Invalid isRequired could likely use a better error message #34

Closed et closed 6 years ago

et commented 6 years ago

I have this as my code:

LoanForm.propTypes = {
  handleSubmit: PropTypes.func.isRequired,
  loan: PropTypes.object.isRequred
};

and received the following error message:

Failed prop type: LoanFormInner: prop type 'loan' is invalid; it must be a function, usually from the 'prop-type' package, but received 'undefined'.

The subtlety is that in loan: PropTypes.object.isRequred, isRequired is spelled wrong. It didn't take me too long to discover the spelling error but the error message didn't really help.

I am curious if you all would be opened to making the error message a little more clear.

ljharb commented 6 years ago

a) this repo is airbnb-prop-types; perhaps you meant facebook's prop-types repo? b) this error message comes from react itself; you'll want to file it there.

et commented 6 years ago

Whoops. Sorry about that.

ljharb commented 6 years ago

(moved to https://github.com/facebook/prop-types/issues/141)