UNPKG

1.62 kBJavaScriptView Raw
1/**
2 * Copyright (c) 2013-present, Facebook, Inc.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8'use strict';
9
10var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
11
12function emptyFunction() {}
13function emptyFunctionWithReset() {}
14emptyFunctionWithReset.resetWarningCache = emptyFunction;
15
16module.exports = function() {
17 function shim(props, propName, componentName, location, propFullName, secret) {
18 if (secret === ReactPropTypesSecret) {
19 // It is still safe when called from React.
20 return;
21 }
22 var err = new Error(
23 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
24 'Use PropTypes.checkPropTypes() to call them. ' +
25 'Read more at http://fb.me/use-check-prop-types'
26 );
27 err.name = 'Invariant Violation';
28 throw err;
29 };
30 shim.isRequired = shim;
31 function getShim() {
32 return shim;
33 };
34 // Important!
35 // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
36 var ReactPropTypes = {
37 array: shim,
38 bool: shim,
39 func: shim,
40 number: shim,
41 object: shim,
42 string: shim,
43 symbol: shim,
44
45 any: shim,
46 arrayOf: getShim,
47 element: shim,
48 elementType: shim,
49 instanceOf: getShim,
50 node: shim,
51 objectOf: getShim,
52 oneOf: getShim,
53 oneOfType: getShim,
54 shape: getShim,
55 exact: getShim,
56
57 checkPropTypes: emptyFunctionWithReset,
58 resetWarningCache: emptyFunction
59 };
60
61 ReactPropTypes.PropTypes = ReactPropTypes;
62
63 return ReactPropTypes;
64};