From 1c02cc29181b66e23b93d4f0cf2c2898cd6e3a01 Mon Sep 17 00:00:00 2001 From: Titouan Rigoudy Date: Fri, 11 Mar 2016 16:54:21 +0100 Subject: [PATCH] Add location to propTypeRequiredWrapper error message. --- src/utils/propTypeRequiredWrapper.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/utils/propTypeRequiredWrapper.js b/src/utils/propTypeRequiredWrapper.js index da57263..34f52e3 100644 --- a/src/utils/propTypeRequiredWrapper.js +++ b/src/utils/propTypeRequiredWrapper.js @@ -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}\`.` ); };