UNPKG

1.47 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() {}
13
14module.exports = function() {
15 function shim(props, propName, componentName, location, propFullName, secret) {
16 if (secret === ReactPropTypesSecret) {
17 // It is still safe when called from React.
18 return;
19 }
20 var err = new Error(
21 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
22 'Use PropTypes.checkPropTypes() to call them. ' +
23 'Read more at http://fb.me/use-check-prop-types'
24 );
25 err.name = 'Invariant Violation';
26 throw err;
27 };
28 shim.isRequired = shim;
29 function getShim() {
30 return shim;
31 };
32 // Important!
33 // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
34 var ReactPropTypes = {
35 array: shim,
36 bool: shim,
37 func: shim,
38 number: shim,
39 object: shim,
40 string: shim,
41 symbol: shim,
42
43 any: shim,
44 arrayOf: getShim,
45 element: shim,
46 instanceOf: getShim,
47 node: shim,
48 objectOf: getShim,
49 oneOf: getShim,
50 oneOfType: getShim,
51 shape: getShim,
52 exact: getShim
53 };
54
55 ReactPropTypes.checkPropTypes = emptyFunction;
56 ReactPropTypes.PropTypes = ReactPropTypes;
57
58 return ReactPropTypes;
59};