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