use-sync-external-store.development.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * @license React
  3. * use-sync-external-store.development.js
  4. *
  5. * Copyright (c) Facebook, Inc. and its affiliates.
  6. *
  7. * This source code is licensed under the MIT license found in the
  8. * LICENSE file in the root directory of this source tree.
  9. */
  10. 'use strict';
  11. if (process.env.NODE_ENV !== "production") {
  12. (function() {
  13. 'use strict';
  14. /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
  15. if (
  16. typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
  17. typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
  18. 'function'
  19. ) {
  20. __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
  21. }
  22. var React = require('react');
  23. var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
  24. function error(format) {
  25. {
  26. {
  27. for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  28. args[_key2 - 1] = arguments[_key2];
  29. }
  30. printWarning('error', format, args);
  31. }
  32. }
  33. }
  34. function printWarning(level, format, args) {
  35. // When changing this logic, you might want to also
  36. // update consoleWithStackDev.www.js as well.
  37. {
  38. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  39. var stack = ReactDebugCurrentFrame.getStackAddendum();
  40. if (stack !== '') {
  41. format += '%s';
  42. args = args.concat([stack]);
  43. } // eslint-disable-next-line react-internal/safe-string-coercion
  44. var argsWithFormat = args.map(function (item) {
  45. return String(item);
  46. }); // Careful: RN currently depends on this prefix
  47. argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
  48. // breaks IE9: https://github.com/facebook/react/issues/13610
  49. // eslint-disable-next-line react-internal/no-production-logging
  50. Function.prototype.apply.call(console[level], console, argsWithFormat);
  51. }
  52. }
  53. var useSyncExternalStore = React.useSyncExternalStore;
  54. {
  55. error("The main 'use-sync-external-store' entry point is not supported; all it " + "does is re-export useSyncExternalStore from the 'react' package, so " + 'it only works with React 18+.' + '\n\n' + 'If you wish to support React 16 and 17, import from ' + "'use-sync-external-store/shim' instead. It will fall back to a shimmed " + 'implementation when the native one is not available.' + '\n\n' + "If you only support React 18+, you can import directly from 'react'.");
  56. }
  57. exports.useSyncExternalStore = useSyncExternalStore;
  58. /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
  59. if (
  60. typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
  61. typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
  62. 'function'
  63. ) {
  64. __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
  65. }
  66. })();
  67. }