react-is.development.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /** @license React v16.13.1
  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. 'use strict';
  10. (function (global, factory) {
  11. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  12. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  13. (global = global || self, factory(global.ReactIs = {}));
  14. }(this, (function (exports) { 'use strict';
  15. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  16. // nor polyfill, then a plain number is used for performance.
  17. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  18. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
  19. var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
  20. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
  21. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
  22. var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
  23. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
  24. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
  25. // (unstable) APIs that have been removed. Can we remove the symbols?
  26. var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
  27. var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
  28. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
  29. var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
  30. var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
  31. var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
  32. var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
  33. var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
  34. var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
  35. var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
  36. var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
  37. function isValidElementType(type) {
  38. return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
  39. type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_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 || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
  40. }
  41. function typeOf(object) {
  42. if (typeof object === 'object' && object !== null) {
  43. var $$typeof = object.$$typeof;
  44. switch ($$typeof) {
  45. case REACT_ELEMENT_TYPE:
  46. var type = object.type;
  47. switch (type) {
  48. case REACT_ASYNC_MODE_TYPE:
  49. case REACT_CONCURRENT_MODE_TYPE:
  50. case REACT_FRAGMENT_TYPE:
  51. case REACT_PROFILER_TYPE:
  52. case REACT_STRICT_MODE_TYPE:
  53. case REACT_SUSPENSE_TYPE:
  54. return type;
  55. default:
  56. var $$typeofType = type && type.$$typeof;
  57. switch ($$typeofType) {
  58. case REACT_CONTEXT_TYPE:
  59. case REACT_FORWARD_REF_TYPE:
  60. case REACT_LAZY_TYPE:
  61. case REACT_MEMO_TYPE:
  62. case REACT_PROVIDER_TYPE:
  63. return $$typeofType;
  64. default:
  65. return $$typeof;
  66. }
  67. }
  68. case REACT_PORTAL_TYPE:
  69. return $$typeof;
  70. }
  71. }
  72. return undefined;
  73. } // AsyncMode is deprecated along with isAsyncMode
  74. var AsyncMode = REACT_ASYNC_MODE_TYPE;
  75. var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
  76. var ContextConsumer = REACT_CONTEXT_TYPE;
  77. var ContextProvider = REACT_PROVIDER_TYPE;
  78. var Element = REACT_ELEMENT_TYPE;
  79. var ForwardRef = REACT_FORWARD_REF_TYPE;
  80. var Fragment = REACT_FRAGMENT_TYPE;
  81. var Lazy = REACT_LAZY_TYPE;
  82. var Memo = REACT_MEMO_TYPE;
  83. var Portal = REACT_PORTAL_TYPE;
  84. var Profiler = REACT_PROFILER_TYPE;
  85. var StrictMode = REACT_STRICT_MODE_TYPE;
  86. var Suspense = REACT_SUSPENSE_TYPE;
  87. var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
  88. function isAsyncMode(object) {
  89. {
  90. if (!hasWarnedAboutDeprecatedIsAsyncMode) {
  91. hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
  92. console['warn']('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.');
  93. }
  94. }
  95. return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
  96. }
  97. function isConcurrentMode(object) {
  98. return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
  99. }
  100. function isContextConsumer(object) {
  101. return typeOf(object) === REACT_CONTEXT_TYPE;
  102. }
  103. function isContextProvider(object) {
  104. return typeOf(object) === REACT_PROVIDER_TYPE;
  105. }
  106. function isElement(object) {
  107. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  108. }
  109. function isForwardRef(object) {
  110. return typeOf(object) === REACT_FORWARD_REF_TYPE;
  111. }
  112. function isFragment(object) {
  113. return typeOf(object) === REACT_FRAGMENT_TYPE;
  114. }
  115. function isLazy(object) {
  116. return typeOf(object) === REACT_LAZY_TYPE;
  117. }
  118. function isMemo(object) {
  119. return typeOf(object) === REACT_MEMO_TYPE;
  120. }
  121. function isPortal(object) {
  122. return typeOf(object) === REACT_PORTAL_TYPE;
  123. }
  124. function isProfiler(object) {
  125. return typeOf(object) === REACT_PROFILER_TYPE;
  126. }
  127. function isStrictMode(object) {
  128. return typeOf(object) === REACT_STRICT_MODE_TYPE;
  129. }
  130. function isSuspense(object) {
  131. return typeOf(object) === REACT_SUSPENSE_TYPE;
  132. }
  133. exports.AsyncMode = AsyncMode;
  134. exports.ConcurrentMode = ConcurrentMode;
  135. exports.ContextConsumer = ContextConsumer;
  136. exports.ContextProvider = ContextProvider;
  137. exports.Element = Element;
  138. exports.ForwardRef = ForwardRef;
  139. exports.Fragment = Fragment;
  140. exports.Lazy = Lazy;
  141. exports.Memo = Memo;
  142. exports.Portal = Portal;
  143. exports.Profiler = Profiler;
  144. exports.StrictMode = StrictMode;
  145. exports.Suspense = Suspense;
  146. exports.isAsyncMode = isAsyncMode;
  147. exports.isConcurrentMode = isConcurrentMode;
  148. exports.isContextConsumer = isContextConsumer;
  149. exports.isContextProvider = isContextProvider;
  150. exports.isElement = isElement;
  151. exports.isForwardRef = isForwardRef;
  152. exports.isFragment = isFragment;
  153. exports.isLazy = isLazy;
  154. exports.isMemo = isMemo;
  155. exports.isPortal = isPortal;
  156. exports.isProfiler = isProfiler;
  157. exports.isStrictMode = isStrictMode;
  158. exports.isSuspense = isSuspense;
  159. exports.isValidElementType = isValidElementType;
  160. exports.typeOf = typeOf;
  161. })));