From 118249e4fd10ed3dc6298111869551def90dadde Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Fri, 12 May 2017 15:43:10 +0100 Subject: [PATCH] Fix false positive when mixing DEV and PROD builds --- factoryWithThrowingShims.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/factoryWithThrowingShims.js b/factoryWithThrowingShims.js index 257f710..840f68e 100644 --- a/factoryWithThrowingShims.js +++ b/factoryWithThrowingShims.js @@ -11,11 +11,14 @@ var emptyFunction = require('fbjs/lib/emptyFunction'); var invariant = require('fbjs/lib/invariant'); +var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); module.exports = function() { - // Important! - // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. - function shim() { + function shim(props, propName, componentName, location, propFullName, secret) { + if (secret === ReactPropTypesSecret) { + // It is still safe when called from React. + return; + } invariant( false, 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + @@ -27,6 +30,8 @@ module.exports = function() { function getShim() { return shim; }; + // Important! + // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. var ReactPropTypes = { array: shim, bool: shim,