Browse Source

Add location to propTypeRequiredWrapper error message.

pull/1/head
Titouan Rigoudy 9 years ago
parent
commit
1c02cc2918
1 changed files with 8 additions and 3 deletions
  1. +8
    -3
      src/utils/propTypeRequiredWrapper.js

+ 8
- 3
src/utils/propTypeRequiredWrapper.js View File

@ -1,11 +1,16 @@
const checkRequiredThenValidate = (validator) =>
(props, propName, componentName, ...rest) =>
(props, propName, componentName, location) =>
{
if (props[propName] !== null) {
return validator(props, propName, componentName, ...rest);
return validator(props, propName, componentName, location);
}
/* global ReactPropTypesLocationNames */ // Pacify ESLint
const location_name = ReactPropTypesLocationNames[location];
return new Error(
`Missing prop \`${propName}\` not supplied to \`${componentName}\``
`Required prop \`${propName}\` was not specified in ` +
`\`${componentName}\`. Check the render method of \`${location_name}\`.`
);
};


Loading…
Cancel
Save