UNPKG

8.07 kBJavaScriptView Raw
1/** @license React v16.8.0
2 * react-is.development.js
3 *
4 * Copyright (c) Facebook, Inc. and its affiliates.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the root directory of this source tree.
8 */
9
10'use strict';
11
12
13
14if (process.env.NODE_ENV !== "production") {
15 (function() {
16'use strict';
17
18Object.defineProperty(exports, '__esModule', { value: true });
19
20// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
21// nor polyfill, then a plain number is used for performance.
22var hasSymbol = typeof Symbol === 'function' && Symbol.for;
23
24var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
25var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
26var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
27var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
28var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
29var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
30var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
31var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
32var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
33var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
34var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
35var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
36var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
37
38function isValidElementType(type) {
39 return typeof type === 'string' || typeof type === 'function' ||
40 // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
41 type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
42}
43
44/**
45 * Forked from fbjs/warning:
46 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
47 *
48 * Only change is we use console.warn instead of console.error,
49 * and do nothing when 'console' is not supported.
50 * This really simplifies the code.
51 * ---
52 * Similar to invariant but only logs a warning if the condition is not met.
53 * This can be used to log issues in development environments in critical
54 * paths. Removing the logging code for production environments will keep the
55 * same logic and follow the same code paths.
56 */
57
58var lowPriorityWarning = function () {};
59
60{
61 var printWarning = function (format) {
62 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
63 args[_key - 1] = arguments[_key];
64 }
65
66 var argIndex = 0;
67 var message = 'Warning: ' + format.replace(/%s/g, function () {
68 return args[argIndex++];
69 });
70 if (typeof console !== 'undefined') {
71 console.warn(message);
72 }
73 try {
74 // --- Welcome to debugging React ---
75 // This error was thrown as a convenience so that you can use this stack
76 // to find the callsite that caused this warning to fire.
77 throw new Error(message);
78 } catch (x) {}
79 };
80
81 lowPriorityWarning = function (condition, format) {
82 if (format === undefined) {
83 throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
84 }
85 if (!condition) {
86 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
87 args[_key2 - 2] = arguments[_key2];
88 }
89
90 printWarning.apply(undefined, [format].concat(args));
91 }
92 };
93}
94
95var lowPriorityWarning$1 = lowPriorityWarning;
96
97function typeOf(object) {
98 if (typeof object === 'object' && object !== null) {
99 var $$typeof = object.$$typeof;
100 switch ($$typeof) {
101 case REACT_ELEMENT_TYPE:
102 var type = object.type;
103
104 switch (type) {
105 case REACT_ASYNC_MODE_TYPE:
106 case REACT_CONCURRENT_MODE_TYPE:
107 case REACT_FRAGMENT_TYPE:
108 case REACT_PROFILER_TYPE:
109 case REACT_STRICT_MODE_TYPE:
110 case REACT_SUSPENSE_TYPE:
111 return type;
112 default:
113 var $$typeofType = type && type.$$typeof;
114
115 switch ($$typeofType) {
116 case REACT_CONTEXT_TYPE:
117 case REACT_FORWARD_REF_TYPE:
118 case REACT_PROVIDER_TYPE:
119 return $$typeofType;
120 default:
121 return $$typeof;
122 }
123 }
124 case REACT_LAZY_TYPE:
125 case REACT_MEMO_TYPE:
126 case REACT_PORTAL_TYPE:
127 return $$typeof;
128 }
129 }
130
131 return undefined;
132}
133
134// AsyncMode is deprecated along with isAsyncMode
135var AsyncMode = REACT_ASYNC_MODE_TYPE;
136var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
137var ContextConsumer = REACT_CONTEXT_TYPE;
138var ContextProvider = REACT_PROVIDER_TYPE;
139var Element = REACT_ELEMENT_TYPE;
140var ForwardRef = REACT_FORWARD_REF_TYPE;
141var Fragment = REACT_FRAGMENT_TYPE;
142var Lazy = REACT_LAZY_TYPE;
143var Memo = REACT_MEMO_TYPE;
144var Portal = REACT_PORTAL_TYPE;
145var Profiler = REACT_PROFILER_TYPE;
146var StrictMode = REACT_STRICT_MODE_TYPE;
147var Suspense = REACT_SUSPENSE_TYPE;
148
149var hasWarnedAboutDeprecatedIsAsyncMode = false;
150
151// AsyncMode should be deprecated
152function isAsyncMode(object) {
153 {
154 if (!hasWarnedAboutDeprecatedIsAsyncMode) {
155 hasWarnedAboutDeprecatedIsAsyncMode = true;
156 lowPriorityWarning$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
157 }
158 }
159 return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
160}
161function isConcurrentMode(object) {
162 return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
163}
164function isContextConsumer(object) {
165 return typeOf(object) === REACT_CONTEXT_TYPE;
166}
167function isContextProvider(object) {
168 return typeOf(object) === REACT_PROVIDER_TYPE;
169}
170function isElement(object) {
171 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
172}
173function isForwardRef(object) {
174 return typeOf(object) === REACT_FORWARD_REF_TYPE;
175}
176function isFragment(object) {
177 return typeOf(object) === REACT_FRAGMENT_TYPE;
178}
179function isLazy(object) {
180 return typeOf(object) === REACT_LAZY_TYPE;
181}
182function isMemo(object) {
183 return typeOf(object) === REACT_MEMO_TYPE;
184}
185function isPortal(object) {
186 return typeOf(object) === REACT_PORTAL_TYPE;
187}
188function isProfiler(object) {
189 return typeOf(object) === REACT_PROFILER_TYPE;
190}
191function isStrictMode(object) {
192 return typeOf(object) === REACT_STRICT_MODE_TYPE;
193}
194function isSuspense(object) {
195 return typeOf(object) === REACT_SUSPENSE_TYPE;
196}
197
198exports.typeOf = typeOf;
199exports.AsyncMode = AsyncMode;
200exports.ConcurrentMode = ConcurrentMode;
201exports.ContextConsumer = ContextConsumer;
202exports.ContextProvider = ContextProvider;
203exports.Element = Element;
204exports.ForwardRef = ForwardRef;
205exports.Fragment = Fragment;
206exports.Lazy = Lazy;
207exports.Memo = Memo;
208exports.Portal = Portal;
209exports.Profiler = Profiler;
210exports.StrictMode = StrictMode;
211exports.Suspense = Suspense;
212exports.isValidElementType = isValidElementType;
213exports.isAsyncMode = isAsyncMode;
214exports.isConcurrentMode = isConcurrentMode;
215exports.isContextConsumer = isContextConsumer;
216exports.isContextProvider = isContextProvider;
217exports.isElement = isElement;
218exports.isForwardRef = isForwardRef;
219exports.isFragment = isFragment;
220exports.isLazy = isLazy;
221exports.isMemo = isMemo;
222exports.isPortal = isPortal;
223exports.isProfiler = isProfiler;
224exports.isStrictMode = isStrictMode;
225exports.isSuspense = isSuspense;
226 })();
227}