From 71bdfe3c105e05fcfa3cca2018611e3380ff3ae0 Mon Sep 17 00:00:00 2001 From: Gregory Desfour Date: Sun, 14 May 2017 01:52:15 +0800 Subject: [PATCH] `checkPropTypes`: Friendlier message when using a type checker that is not a function --- checkPropTypes.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/checkPropTypes.js b/checkPropTypes.js index 49111df..1ad29fe 100644 --- a/checkPropTypes.js +++ b/checkPropTypes.js @@ -53,7 +53,8 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) { if (typeof typeSpecs[typeSpecName] !== 'function') { var err = Error( (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + - 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.' ); err.name = 'Invariant Violation'; throw err;