@office-iss/react-native-win32 0.66.4 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/.eslintignore +2 -0
  2. package/.flowconfig +1 -1
  3. package/CHANGELOG.json +228 -46
  4. package/CHANGELOG.md +102 -25
  5. package/Libraries/ActionSheetIOS/ActionSheetIOS.js +14 -1
  6. package/Libraries/ActionSheetIOS/NativeActionSheetManager.js +2 -0
  7. package/Libraries/Animated/AnimatedEvent.js +23 -4
  8. package/Libraries/Animated/NativeAnimatedHelper.js +2 -2
  9. package/Libraries/Animated/components/AnimatedImage.js +3 -3
  10. package/Libraries/Animated/components/AnimatedScrollView.js +3 -3
  11. package/Libraries/Animated/components/AnimatedText.js +3 -3
  12. package/Libraries/Animated/components/AnimatedView.js +1 -3
  13. package/Libraries/Animated/createAnimatedComponent.js +3 -34
  14. package/Libraries/Components/Button/ButtonWin32.js +2 -2
  15. package/Libraries/Components/Button/ButtonWin32.js.map +1 -1
  16. package/Libraries/Components/Button.js +3 -0
  17. package/Libraries/Components/DatePicker/DatePickerIOS.ios.js +3 -6
  18. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +4 -7
  19. package/Libraries/Components/EnterString.win32.js +3 -3
  20. package/Libraries/Components/EnterString.win32.js.map +1 -1
  21. package/Libraries/Components/Keyboard/Keyboard.js +2 -2
  22. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +1 -0
  23. package/Libraries/Components/ScrollView/ScrollView.js +17 -16
  24. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +268 -252
  25. package/Libraries/Components/Text/Tests/TextWin32Test.d.ts +0 -1
  26. package/Libraries/Components/Text/TextWin32.Props.d.ts +2 -2
  27. package/Libraries/Components/Text/TextWin32.Props.js.map +1 -1
  28. package/Libraries/Components/Text/TextWin32.js +1 -1
  29. package/Libraries/Components/Text/TextWin32.js.map +1 -1
  30. package/Libraries/Components/TextInput/Tests/TextInputTest.d.ts +0 -1
  31. package/Libraries/Components/TextInput/TextInput.win32.js +6 -6
  32. package/Libraries/Components/TextInput/TextInput.win32.js.map +1 -1
  33. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.d.ts +0 -1
  34. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js +1 -1
  35. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
  36. package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +2 -2
  37. package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js.map +1 -1
  38. package/Libraries/Components/Touchable/TouchableWin32.js +2 -2
  39. package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
  40. package/Libraries/Components/View/Tests/ViewWin32Test.d.ts +0 -1
  41. package/Libraries/Components/View/View.js +1 -1
  42. package/Libraries/Components/View/View.win32.js +1 -1
  43. package/Libraries/Components/View/ViewAccessibility.js +1 -1
  44. package/Libraries/Components/View/ViewWin32.Props.d.ts +3 -6
  45. package/Libraries/Components/View/ViewWin32.Props.js.map +1 -1
  46. package/Libraries/Components/View/ViewWin32.js +5 -5
  47. package/Libraries/Components/View/ViewWin32.js.map +1 -1
  48. package/Libraries/Core/ExceptionsManager.js +45 -80
  49. package/Libraries/Core/ExtendedError.js +0 -1
  50. package/Libraries/Core/ReactNativeVersion.js +3 -3
  51. package/Libraries/Core/setUpBatchedBridge.js +1 -1
  52. package/Libraries/Core/setUpGlobals.js +2 -4
  53. package/Libraries/Core/setUpTimers.js +2 -2
  54. package/Libraries/Image/Image.ios.js +6 -0
  55. package/Libraries/Image/Image.win32.js +6 -0
  56. package/Libraries/Image/ImageBackground.js +10 -8
  57. package/Libraries/Image/ImageProps.js +28 -0
  58. package/Libraries/Image/Tests/ImageWin32Test.d.ts +0 -1
  59. package/Libraries/LogBox/Data/LogBoxData.js +18 -19
  60. package/Libraries/LogBox/UI/LogBoxImages/alert-triangle.png +0 -0
  61. package/Libraries/LogBox/UI/LogBoxImages/chevron-left.png +0 -0
  62. package/Libraries/LogBox/UI/LogBoxImages/chevron-right.png +0 -0
  63. package/Libraries/LogBox/UI/LogBoxImages/close.png +0 -0
  64. package/Libraries/LogBox/UI/LogBoxImages/loader.png +0 -0
  65. package/Libraries/NewAppScreen/components/logo.png +0 -0
  66. package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +2 -1
  67. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +2 -0
  68. package/Libraries/PersonaCoin/PersonaCoin.js +3 -2
  69. package/Libraries/PersonaCoin/PersonaCoin.js.map +1 -1
  70. package/Libraries/Pressability/Pressability.js +13 -13
  71. package/Libraries/Pressability/Pressability.win32.js +13 -13
  72. package/Libraries/Pressability/PressabilityPerformanceEventEmitter.js +1 -1
  73. package/Libraries/ReactNative/AppRegistry.js +4 -2
  74. package/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +1569 -875
  75. package/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +529 -319
  76. package/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +570 -362
  77. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +1592 -891
  78. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +521 -311
  79. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +562 -354
  80. package/Libraries/Share/Share.js +1 -1
  81. package/Libraries/StyleSheet/normalizeColor.js +2 -2
  82. package/Libraries/Text/TextProps.js +1 -7
  83. package/Libraries/TurboModule/TurboModuleRegistry.js +1 -1
  84. package/Libraries/Utilities/HMRClient.js +1 -1
  85. package/flow/global.js +45 -0
  86. package/index.js +15 -10
  87. package/index.win32.js +15 -10
  88. package/jest/mockModal.js +31 -0
  89. package/jest/preprocessor.js +7 -75
  90. package/jest/setup.js +5 -3
  91. package/overrides.json +8 -14
  92. package/package.json +19 -17
  93. package/rntypes/BatchedBridge.d.ts +23 -0
  94. package/rntypes/Devtools.d.ts +20 -0
  95. package/rntypes/LaunchScreen.d.ts +9 -0
  96. package/rntypes/globals.d.ts +496 -0
  97. package/rntypes/index.d.ts +9966 -0
  98. package/rntypes/legacy-properties.d.ts +266 -0
  99. package/src/Libraries/Components/Text/TextWin32.Props.ts +2 -2
  100. package/src/Libraries/Components/View/ViewWin32.Props.ts +6 -12
  101. package/src/rntypes/BatchedBridge.d.ts +23 -0
  102. package/src/rntypes/Devtools.d.ts +20 -0
  103. package/src/rntypes/LaunchScreen.d.ts +9 -0
  104. package/src/rntypes/globals.d.ts +496 -0
  105. package/src/rntypes/index.d.ts +9966 -0
  106. package/src/rntypes/legacy-properties.d.ts +266 -0
  107. package/src/typings-index.ts +11 -4
  108. package/typings-index.d.ts +3 -1
  109. package/typings-index.js +7 -5
  110. package/typings-index.js.map +1 -1
  111. package/Libraries/Components/DatePickerAndroid/DatePickerAndroid.android.js +0 -87
  112. package/Libraries/Components/DatePickerAndroid/DatePickerAndroid.ios.js +0 -30
  113. package/Libraries/Components/DatePickerAndroid/DatePickerAndroid.win32.js +0 -30
  114. package/Libraries/Components/DatePickerAndroid/DatePickerAndroidTypes.js +0 -30
  115. package/Libraries/Components/StaticContainer.react.js +0 -51
  116. package/Libraries/Components/Touchable/ensurePositiveDelayProps.js +0 -25
  117. package/Libraries/Interaction/InteractionMixin.js +0 -54
  118. package/Libraries/ReactNative/queryLayoutByID.js +0 -58
@@ -7,7 +7,7 @@
7
7
  * @noflow
8
8
  * @nolint
9
9
  * @preventMunge
10
- * @generated SignedSource<<0105b67942f03415395650d296aa846a>>
10
+ * @generated SignedSource<<d652a63f09b72c44e6b8e592ebfd0790>>
11
11
  */
12
12
 
13
13
  'use strict';
@@ -32,32 +32,36 @@ var ReactSharedInternals =
32
32
 
33
33
  function warn(format) {
34
34
  {
35
- for (
36
- var _len = arguments.length,
37
- args = new Array(_len > 1 ? _len - 1 : 0),
38
- _key = 1;
39
- _key < _len;
40
- _key++
41
- ) {
42
- args[_key - 1] = arguments[_key];
43
- }
35
+ {
36
+ for (
37
+ var _len = arguments.length,
38
+ args = new Array(_len > 1 ? _len - 1 : 0),
39
+ _key = 1;
40
+ _key < _len;
41
+ _key++
42
+ ) {
43
+ args[_key - 1] = arguments[_key];
44
+ }
44
45
 
45
- printWarning("warn", format, args);
46
+ printWarning("warn", format, args);
47
+ }
46
48
  }
47
49
  }
48
50
  function error(format) {
49
51
  {
50
- for (
51
- var _len2 = arguments.length,
52
- args = new Array(_len2 > 1 ? _len2 - 1 : 0),
53
- _key2 = 1;
54
- _key2 < _len2;
55
- _key2++
56
- ) {
57
- args[_key2 - 1] = arguments[_key2];
58
- }
52
+ {
53
+ for (
54
+ var _len2 = arguments.length,
55
+ args = new Array(_len2 > 1 ? _len2 - 1 : 0),
56
+ _key2 = 1;
57
+ _key2 < _len2;
58
+ _key2++
59
+ ) {
60
+ args[_key2 - 1] = arguments[_key2];
61
+ }
59
62
 
60
- printWarning("error", format, args);
63
+ printWarning("error", format, args);
64
+ }
61
65
  }
62
66
  }
63
67
 
@@ -71,10 +75,10 @@ function printWarning(level, format, args) {
71
75
  if (stack !== "") {
72
76
  format += "%s";
73
77
  args = args.concat([stack]);
74
- }
78
+ } // eslint-disable-next-line react-internal/safe-string-coercion
75
79
 
76
80
  var argsWithFormat = args.map(function(item) {
77
- return "" + item;
81
+ return String(item);
78
82
  }); // Careful: RN currently depends on this prefix
79
83
 
80
84
  argsWithFormat.unshift("Warning: " + format); // We intentionally don't use spread (or .apply) directly because it
@@ -141,9 +145,15 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd;
141
145
  // when we call document.createEvent(). However this can cause confusing
142
146
  // errors: https://github.com/facebook/create-react-app/issues/3482
143
147
  // So we preemptively throw with a better message instead.
144
- if (!(typeof document !== "undefined")) {
145
- throw Error(
146
- "The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous."
148
+ if (typeof document === "undefined") {
149
+ throw new Error(
150
+ "The `document` global was defined when React was initialized, but is not " +
151
+ "defined anymore. This can happen in a test environment if a component " +
152
+ "schedules an update from an asynchronous callback, but the test has already " +
153
+ "finished running. To solve this, you can either unmount the component at " +
154
+ "the end of your test (and ensure that any asynchronous operations get " +
155
+ "canceled in `componentWillUnmount`), or you can change the test itself " +
156
+ "to be asynchronous."
147
157
  );
148
158
  }
149
159
 
@@ -249,6 +259,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd;
249
259
  if (didCall && didError) {
250
260
  if (!didSetError) {
251
261
  // The callback errored, but the error event never fired.
262
+ // eslint-disable-next-line react-internal/prod-error-codes
252
263
  error = new Error(
253
264
  "An error was thrown inside one of your components, but React " +
254
265
  "doesn't know what it was. This is likely due to browser " +
@@ -260,6 +271,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd;
260
271
  "actually an issue with React, please file an issue."
261
272
  );
262
273
  } else if (isCrossOriginError) {
274
+ // eslint-disable-next-line react-internal/prod-error-codes
263
275
  error = new Error(
264
276
  "A cross-origin error was thrown. React doesn't have access to " +
265
277
  "the actual error object in development. " +
@@ -372,11 +384,10 @@ function clearCaughtError() {
372
384
  caughtError = null;
373
385
  return error;
374
386
  } else {
375
- {
376
- throw Error(
377
- "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue."
378
- );
379
- }
387
+ throw new Error(
388
+ "clearCaughtError was called but no error was captured. This error " +
389
+ "is likely caused by a bug in React. Please file an issue."
390
+ );
380
391
  }
381
392
  }
382
393
 
@@ -533,8 +544,8 @@ function executeDirectDispatch(event) {
533
544
  var dispatchListener = event._dispatchListeners;
534
545
  var dispatchInstance = event._dispatchInstances;
535
546
 
536
- if (!!isArray(dispatchListener)) {
537
- throw Error("executeDirectDispatch(...): Invalid `event`.");
547
+ if (isArray(dispatchListener)) {
548
+ throw new Error("executeDirectDispatch(...): Invalid `event`.");
538
549
  }
539
550
 
540
551
  event.currentTarget = dispatchListener
@@ -555,6 +566,7 @@ function hasDispatches(event) {
555
566
  return !!event._dispatchListeners;
556
567
  }
557
568
 
569
+ /* eslint valid-typeof: 0 */
558
570
  var EVENT_POOL_SIZE = 10;
559
571
  /**
560
572
  * @interface Event
@@ -881,7 +893,7 @@ function releasePooledEvent(event) {
881
893
  var EventConstructor = this;
882
894
 
883
895
  if (!(event instanceof EventConstructor)) {
884
- throw Error(
896
+ throw new Error(
885
897
  "Trying to release an event instance into a pool of a different type."
886
898
  );
887
899
  }
@@ -990,8 +1002,8 @@ function resetTouchRecord(touchRecord, touch) {
990
1002
  function getTouchIdentifier(_ref) {
991
1003
  var identifier = _ref.identifier;
992
1004
 
993
- if (!(identifier != null)) {
994
- throw Error("Touch object is missing identifier.");
1005
+ if (identifier == null) {
1006
+ throw new Error("Touch object is missing identifier.");
995
1007
  }
996
1008
 
997
1009
  {
@@ -1149,8 +1161,8 @@ var ResponderTouchHistoryStore = {
1149
1161
  */
1150
1162
 
1151
1163
  function accumulate(current, next) {
1152
- if (!(next != null)) {
1153
- throw Error(
1164
+ if (next == null) {
1165
+ throw new Error(
1154
1166
  "accumulate(...): Accumulated items must not be null or undefined."
1155
1167
  );
1156
1168
  }
@@ -1185,8 +1197,8 @@ function accumulate(current, next) {
1185
1197
  */
1186
1198
 
1187
1199
  function accumulateInto(current, next) {
1188
- if (!(next != null)) {
1189
- throw Error(
1200
+ if (next == null) {
1201
+ throw new Error(
1190
1202
  "accumulateInto(...): Accumulated items must not be null or undefined."
1191
1203
  );
1192
1204
  }
@@ -1492,8 +1504,8 @@ function getListener(inst, registrationName) {
1492
1504
 
1493
1505
  var listener = props[registrationName];
1494
1506
 
1495
- if (!(!listener || typeof listener === "function")) {
1496
- throw Error(
1507
+ if (listener && typeof listener !== "function") {
1508
+ throw new Error(
1497
1509
  "Expected `" +
1498
1510
  registrationName +
1499
1511
  "` listener to be a function, instead got a value of `" +
@@ -2075,11 +2087,10 @@ function recomputePluginOrdering() {
2075
2087
  var pluginModule = namesToPlugins[pluginName];
2076
2088
  var pluginIndex = eventPluginOrder.indexOf(pluginName);
2077
2089
 
2078
- if (!(pluginIndex > -1)) {
2079
- throw Error(
2080
- "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" +
2081
- pluginName +
2082
- "`."
2090
+ if (pluginIndex <= -1) {
2091
+ throw new Error(
2092
+ "EventPluginRegistry: Cannot inject event plugins that do not exist in " +
2093
+ ("the plugin ordering, `" + pluginName + "`.")
2083
2094
  );
2084
2095
  }
2085
2096
 
@@ -2088,10 +2099,9 @@ function recomputePluginOrdering() {
2088
2099
  }
2089
2100
 
2090
2101
  if (!pluginModule.extractEvents) {
2091
- throw Error(
2092
- "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" +
2093
- pluginName +
2094
- "` does not."
2102
+ throw new Error(
2103
+ "EventPluginRegistry: Event plugins must implement an `extractEvents` " +
2104
+ ("method, but `" + pluginName + "` does not.")
2095
2105
  );
2096
2106
  }
2097
2107
 
@@ -2106,7 +2116,7 @@ function recomputePluginOrdering() {
2106
2116
  eventName
2107
2117
  )
2108
2118
  ) {
2109
- throw Error(
2119
+ throw new Error(
2110
2120
  "EventPluginRegistry: Failed to publish event `" +
2111
2121
  eventName +
2112
2122
  "` for plugin `" +
@@ -2127,11 +2137,10 @@ function recomputePluginOrdering() {
2127
2137
  */
2128
2138
 
2129
2139
  function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
2130
- if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) {
2131
- throw Error(
2132
- "EventPluginRegistry: More than one plugin attempted to publish the same event name, `" +
2133
- eventName +
2134
- "`."
2140
+ if (eventNameDispatchConfigs.hasOwnProperty(eventName)) {
2141
+ throw new Error(
2142
+ "EventPluginRegistry: More than one plugin attempted to publish the same " +
2143
+ ("event name, `" + eventName + "`.")
2135
2144
  );
2136
2145
  }
2137
2146
 
@@ -2171,11 +2180,10 @@ function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
2171
2180
  */
2172
2181
 
2173
2182
  function publishRegistrationName(registrationName, pluginModule, eventName) {
2174
- if (!!registrationNameModules[registrationName]) {
2175
- throw Error(
2176
- "EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" +
2177
- registrationName +
2178
- "`."
2183
+ if (registrationNameModules[registrationName]) {
2184
+ throw new Error(
2185
+ "EventPluginRegistry: More than one plugin attempted to publish the same " +
2186
+ ("registration name, `" + registrationName + "`.")
2179
2187
  );
2180
2188
  }
2181
2189
 
@@ -2222,9 +2230,10 @@ var registrationNameDependencies = {};
2222
2230
  */
2223
2231
 
2224
2232
  function injectEventPluginOrder(injectedEventPluginOrder) {
2225
- if (!!eventPluginOrder) {
2226
- throw Error(
2227
- "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React."
2233
+ if (eventPluginOrder) {
2234
+ throw new Error(
2235
+ "EventPluginRegistry: Cannot inject event plugin ordering more than " +
2236
+ "once. You are likely trying to load more than one copy of React."
2228
2237
  );
2229
2238
  } // Clone the ordering so it cannot be dynamically mutated.
2230
2239
 
@@ -2255,11 +2264,10 @@ function injectEventPluginsByName(injectedNamesToPlugins) {
2255
2264
  !namesToPlugins.hasOwnProperty(pluginName) ||
2256
2265
  namesToPlugins[pluginName] !== pluginModule
2257
2266
  ) {
2258
- if (!!namesToPlugins[pluginName]) {
2259
- throw Error(
2260
- "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" +
2261
- pluginName +
2262
- "`."
2267
+ if (namesToPlugins[pluginName]) {
2268
+ throw new Error(
2269
+ "EventPluginRegistry: Cannot inject two different event plugins " +
2270
+ ("using the same name, `" + pluginName + "`.")
2263
2271
  );
2264
2272
  }
2265
2273
 
@@ -2290,8 +2298,8 @@ function getListener$1(inst, registrationName) {
2290
2298
 
2291
2299
  var listener = props[registrationName];
2292
2300
 
2293
- if (!(!listener || typeof listener === "function")) {
2294
- throw Error(
2301
+ if (listener && typeof listener !== "function") {
2302
+ throw new Error(
2295
2303
  "Expected `" +
2296
2304
  registrationName +
2297
2305
  "` listener to be a function, instead got a value of `" +
@@ -2439,8 +2447,8 @@ var ReactNativeBridgeEventPlugin = {
2439
2447
  var bubbleDispatchConfig = customBubblingEventTypes[topLevelType];
2440
2448
  var directDispatchConfig = customDirectEventTypes[topLevelType];
2441
2449
 
2442
- if (!(bubbleDispatchConfig || directDispatchConfig)) {
2443
- throw Error(
2450
+ if (!bubbleDispatchConfig && !directDispatchConfig) {
2451
+ throw new Error( // $FlowFixMe - Flow doesn't like this string coercion because DOMTopLevelEventType is opaque
2444
2452
  'Unsupported top level event type "' + topLevelType + '" dispatched'
2445
2453
  );
2446
2454
  }
@@ -2498,7 +2506,7 @@ function getTagFromInstance(inst) {
2498
2506
  var nativeInstance = inst.stateNode.canonical;
2499
2507
 
2500
2508
  if (!nativeInstance._nativeTag) {
2501
- throw Error("All native instances should have a tag.");
2509
+ throw new Error("All native instances should have a tag.");
2502
2510
  }
2503
2511
 
2504
2512
  return nativeInstance;
@@ -2845,10 +2853,12 @@ function getComponentNameFromFiber(fiber) {
2845
2853
 
2846
2854
  var enablePersistentOffscreenHostContainer =
2847
2855
  dynamicFlags.enablePersistentOffscreenHostContainer; // The rest of the flags are static for better dead code elimination.
2856
+ var enableSchedulingProfiler = false;
2848
2857
  var enableProfilerTimer = true;
2849
2858
  var enableProfilerCommitHooks = true;
2850
2859
  var enableLazyElements = false;
2851
2860
  var warnAboutStringRefs = false;
2861
+ var warnOnSubscriptionInsideStartTransition = false;
2852
2862
  var enableNewReconciler = false;
2853
2863
  var enableLazyContextPropagation = false;
2854
2864
 
@@ -2883,37 +2893,41 @@ var DidCapture =
2883
2893
  128;
2884
2894
  var Ref =
2885
2895
  /* */
2886
- 256;
2896
+ 512;
2887
2897
  var Snapshot =
2888
2898
  /* */
2889
- 512;
2899
+ 1024;
2890
2900
  var Passive =
2891
2901
  /* */
2892
- 1024;
2902
+ 2048;
2893
2903
  var Hydrating =
2894
2904
  /* */
2895
- 2048;
2905
+ 4096;
2896
2906
  var HydratingAndUpdate =
2897
2907
  /* */
2898
2908
  Hydrating | Update;
2899
2909
  var Visibility =
2900
2910
  /* */
2901
- 4096;
2902
- var LifecycleEffectMask = Passive | Update | Callback | Ref | Snapshot; // Union of all commit flags (flags with the lifetime of a particular commit)
2911
+ 8192;
2912
+ var StoreConsistency =
2913
+ /* */
2914
+ 16384;
2915
+ var LifecycleEffectMask =
2916
+ Passive | Update | Callback | Ref | Snapshot | StoreConsistency; // Union of all commit flags (flags with the lifetime of a particular commit)
2903
2917
 
2904
2918
  var HostEffectMask =
2905
2919
  /* */
2906
- 8191; // These are not really side effects, but we still reuse this field.
2920
+ 32767; // These are not really side effects, but we still reuse this field.
2907
2921
 
2908
2922
  var Incomplete =
2909
2923
  /* */
2910
- 8192;
2924
+ 32768;
2911
2925
  var ShouldCapture =
2912
2926
  /* */
2913
- 16384;
2927
+ 65536;
2914
2928
  var ForceUpdateForLegacySuspense =
2915
2929
  /* */
2916
- 32768;
2930
+ 131072;
2917
2931
  // e.g. a fiber uses a passive effect (even if there are no updates on this particular render).
2918
2932
  // This enables us to defer more work in the unmount case,
2919
2933
  // since we can defer traversing the tree during layout to look for Passive effects,
@@ -2921,22 +2935,22 @@ var ForceUpdateForLegacySuspense =
2921
2935
 
2922
2936
  var RefStatic =
2923
2937
  /* */
2924
- 262144;
2938
+ 1048576;
2925
2939
  var LayoutStatic =
2926
2940
  /* */
2927
- 524288;
2941
+ 2097152;
2928
2942
  var PassiveStatic =
2929
2943
  /* */
2930
- 1048576; // These flags allow us to traverse to fibers that have effects on mount
2944
+ 4194304; // These flags allow us to traverse to fibers that have effects on mount
2931
2945
  // without traversing the entire tree after every commit for
2932
2946
  // double invoking
2933
2947
 
2934
2948
  var MountLayoutDev =
2935
2949
  /* */
2936
- 2097152;
2950
+ 8388608;
2937
2951
  var MountPassiveDev =
2938
2952
  /* */
2939
- 4194304; // Groups of flags that are used in the commit phase to skip over trees that
2953
+ 16777216; // Groups of flags that are used in the commit phase to skip over trees that
2940
2954
  // don't contain effects, by checking subtreeFlags.
2941
2955
 
2942
2956
  var BeforeMutationMask = // TODO: Remove Update flag from before mutation phase by re-landing Visibility
@@ -3031,8 +3045,8 @@ function isMounted(component) {
3031
3045
  }
3032
3046
 
3033
3047
  function assertIsMounted(fiber) {
3034
- if (!(getNearestMountedFiber(fiber) === fiber)) {
3035
- throw Error("Unable to find node on an unmounted component.");
3048
+ if (getNearestMountedFiber(fiber) !== fiber) {
3049
+ throw new Error("Unable to find node on an unmounted component.");
3036
3050
  }
3037
3051
  }
3038
3052
 
@@ -3043,8 +3057,8 @@ function findCurrentFiberUsingSlowPath(fiber) {
3043
3057
  // If there is no alternate, then we only need to check if it is mounted.
3044
3058
  var nearestMounted = getNearestMountedFiber(fiber);
3045
3059
 
3046
- if (!(nearestMounted !== null)) {
3047
- throw Error("Unable to find node on an unmounted component.");
3060
+ if (nearestMounted === null) {
3061
+ throw new Error("Unable to find node on an unmounted component.");
3048
3062
  }
3049
3063
 
3050
3064
  if (nearestMounted !== fiber) {
@@ -3106,9 +3120,7 @@ function findCurrentFiberUsingSlowPath(fiber) {
3106
3120
  } // We should never have an alternate for any mounting node. So the only
3107
3121
  // way this could possibly happen is if this was unmounted, if at all.
3108
3122
 
3109
- {
3110
- throw Error("Unable to find node on an unmounted component.");
3111
- }
3123
+ throw new Error("Unable to find node on an unmounted component.");
3112
3124
  }
3113
3125
 
3114
3126
  if (a.return !== b.return) {
@@ -3168,23 +3180,25 @@ function findCurrentFiberUsingSlowPath(fiber) {
3168
3180
  }
3169
3181
 
3170
3182
  if (!didFindChild) {
3171
- throw Error(
3172
- "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue."
3183
+ throw new Error(
3184
+ "Child was not found in either parent set. This indicates a bug " +
3185
+ "in React related to the return pointer. Please file an issue."
3173
3186
  );
3174
3187
  }
3175
3188
  }
3176
3189
  }
3177
3190
 
3178
- if (!(a.alternate === b)) {
3179
- throw Error(
3180
- "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue."
3191
+ if (a.alternate !== b) {
3192
+ throw new Error(
3193
+ "Return fibers should always be each others' alternates. " +
3194
+ "This error is likely caused by a bug in React. Please file an issue."
3181
3195
  );
3182
3196
  }
3183
3197
  } // If the root is not a host container, we're in a disconnected tree. I.e.
3184
3198
  // unmounted.
3185
3199
 
3186
- if (!(a.tag === HostRoot)) {
3187
- throw Error("Unable to find node on an unmounted component.");
3200
+ if (a.tag !== HostRoot) {
3201
+ throw new Error("Unable to find node on an unmounted component.");
3188
3202
  }
3189
3203
 
3190
3204
  if (a.stateNode.current === a) {
@@ -3782,9 +3796,10 @@ function runEventsInBatch(events) {
3782
3796
 
3783
3797
  forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel);
3784
3798
 
3785
- if (!!eventQueue) {
3786
- throw Error(
3787
- "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented."
3799
+ if (eventQueue) {
3800
+ throw new Error(
3801
+ "processEventQueue(): Additional events were enqueued while processing " +
3802
+ "an event queue. Support for this has not yet been implemented."
3788
3803
  );
3789
3804
  } // This would be a good time to rethrow if any of the event handlers threw.
3790
3805
 
@@ -3879,6 +3894,103 @@ var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority;
3879
3894
  var NormalPriority = Scheduler.unstable_NormalPriority;
3880
3895
  var IdlePriority = Scheduler.unstable_IdlePriority;
3881
3896
 
3897
+ // Helpers to patch console.logs to avoid logging during side-effect free
3898
+ // replaying on render function. This currently only patches the object
3899
+ // lazily which won't cover if the log function was extracted eagerly.
3900
+ // We could also eagerly patch the method.
3901
+ var disabledDepth = 0;
3902
+ var prevLog;
3903
+ var prevInfo;
3904
+ var prevWarn;
3905
+ var prevError;
3906
+ var prevGroup;
3907
+ var prevGroupCollapsed;
3908
+ var prevGroupEnd;
3909
+
3910
+ function disabledLog() {}
3911
+
3912
+ disabledLog.__reactDisabledLog = true;
3913
+ function disableLogs() {
3914
+ {
3915
+ if (disabledDepth === 0) {
3916
+ /* eslint-disable react-internal/no-production-logging */
3917
+ prevLog = console.log;
3918
+ prevInfo = console.info;
3919
+ prevWarn = console.warn;
3920
+ prevError = console.error;
3921
+ prevGroup = console.group;
3922
+ prevGroupCollapsed = console.groupCollapsed;
3923
+ prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
3924
+
3925
+ var props = {
3926
+ configurable: true,
3927
+ enumerable: true,
3928
+ value: disabledLog,
3929
+ writable: true
3930
+ }; // $FlowFixMe Flow thinks console is immutable.
3931
+
3932
+ Object.defineProperties(console, {
3933
+ info: props,
3934
+ log: props,
3935
+ warn: props,
3936
+ error: props,
3937
+ group: props,
3938
+ groupCollapsed: props,
3939
+ groupEnd: props
3940
+ });
3941
+ /* eslint-enable react-internal/no-production-logging */
3942
+ }
3943
+
3944
+ disabledDepth++;
3945
+ }
3946
+ }
3947
+ function reenableLogs() {
3948
+ {
3949
+ disabledDepth--;
3950
+
3951
+ if (disabledDepth === 0) {
3952
+ /* eslint-disable react-internal/no-production-logging */
3953
+ var props = {
3954
+ configurable: true,
3955
+ enumerable: true,
3956
+ writable: true
3957
+ }; // $FlowFixMe Flow thinks console is immutable.
3958
+
3959
+ Object.defineProperties(console, {
3960
+ log: Object.assign({}, props, {
3961
+ value: prevLog
3962
+ }),
3963
+ info: Object.assign({}, props, {
3964
+ value: prevInfo
3965
+ }),
3966
+ warn: Object.assign({}, props, {
3967
+ value: prevWarn
3968
+ }),
3969
+ error: Object.assign({}, props, {
3970
+ value: prevError
3971
+ }),
3972
+ group: Object.assign({}, props, {
3973
+ value: prevGroup
3974
+ }),
3975
+ groupCollapsed: Object.assign({}, props, {
3976
+ value: prevGroupCollapsed
3977
+ }),
3978
+ groupEnd: Object.assign({}, props, {
3979
+ value: prevGroupEnd
3980
+ })
3981
+ });
3982
+ /* eslint-enable react-internal/no-production-logging */
3983
+ }
3984
+
3985
+ if (disabledDepth < 0) {
3986
+ error(
3987
+ "disabledDepth fell below zero. " +
3988
+ "This is a bug in React. Please file an issue."
3989
+ );
3990
+ }
3991
+ }
3992
+ }
3993
+
3882
3994
  var rendererID = null;
3883
3995
  var injectedHook = null;
3884
3996
  var hasLoggedError = false;
@@ -4030,6 +4142,15 @@ function onCommitUnmount(fiber) {
4030
4142
  }
4031
4143
  }
4032
4144
  }
4145
+ function setIsStrictModeForDevtools(newIsStrictMode) {
4146
+ {
4147
+ if (newIsStrictMode) {
4148
+ disableLogs();
4149
+ } else {
4150
+ reenableLogs();
4151
+ }
4152
+ }
4153
+ }
4033
4154
 
4034
4155
  var NoMode =
4035
4156
  /* */
@@ -4495,16 +4616,10 @@ function includesOnlyRetries(lanes) {
4495
4616
  function includesOnlyTransitions(lanes) {
4496
4617
  return (lanes & TransitionLanes) === lanes;
4497
4618
  }
4498
- function shouldTimeSlice(root, lanes) {
4499
- if ((lanes & root.expiredLanes) !== NoLanes) {
4500
- // At least one of these lanes expired. To prevent additional starvation,
4501
- // finish rendering without yielding execution.
4502
- return false;
4503
- }
4504
-
4619
+ function includesBlockingLane(root, lanes) {
4505
4620
  if ((root.current.mode & ConcurrentUpdatesByDefaultMode) !== NoMode) {
4506
4621
  // Concurrent updates by default always use time slicing.
4507
- return true;
4622
+ return false;
4508
4623
  }
4509
4624
 
4510
4625
  var SyncDefaultLanes =
@@ -4512,7 +4627,12 @@ function shouldTimeSlice(root, lanes) {
4512
4627
  InputContinuousLane |
4513
4628
  DefaultHydrationLane |
4514
4629
  DefaultLane;
4515
- return (lanes & SyncDefaultLanes) === NoLanes;
4630
+ return (lanes & SyncDefaultLanes) !== NoLanes;
4631
+ }
4632
+ function includesExpiredLane(root, lanes) {
4633
+ // This is a separate check from includesBlockingLane because a lane can
4634
+ // expire after a render has already started.
4635
+ return (lanes & root.expiredLanes) !== NoLanes;
4516
4636
  }
4517
4637
  function isTransitionLane(lane) {
4518
4638
  return (lane & TransitionLanes) !== 0;
@@ -4786,28 +4906,28 @@ function lanesToEventPriority(lanes) {
4786
4906
  return IdleEventPriority;
4787
4907
  }
4788
4908
 
4909
+ // Renderers that don't support mutation
4789
4910
  // can re-export everything from this module.
4790
-
4791
4911
  function shim() {
4792
- {
4793
- throw Error(
4794
- "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue."
4795
- );
4796
- }
4912
+ throw new Error(
4913
+ "The current renderer does not support mutation. " +
4914
+ "This error is likely caused by a bug in React. " +
4915
+ "Please file an issue."
4916
+ );
4797
4917
  } // Mutation (when unsupported)
4798
4918
 
4799
4919
  var supportsMutation = false;
4800
4920
  var commitMount = shim;
4801
4921
  var clearContainer = shim;
4802
4922
 
4923
+ // Renderers that don't support hydration
4803
4924
  // can re-export everything from this module.
4804
-
4805
4925
  function shim$1() {
4806
- {
4807
- throw Error(
4808
- "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue."
4809
- );
4810
- }
4926
+ throw new Error(
4927
+ "The current renderer does not support hydration. " +
4928
+ "This error is likely caused by a bug in React. " +
4929
+ "Please file an issue."
4930
+ );
4811
4931
  } // Hydration (when unsupported)
4812
4932
  var isSuspenseInstancePending = shim$1;
4813
4933
  var isSuspenseInstanceFallback = shim$1;
@@ -5187,150 +5307,53 @@ function preparePortalMount(portalInstance) {
5187
5307
  // noop
5188
5308
  }
5189
5309
 
5190
- // Helpers to patch console.logs to avoid logging during side-effect free
5191
- // replaying on render function. This currently only patches the object
5192
- // lazily which won't cover if the log function was extracted eagerly.
5193
- // We could also eagerly patch the method.
5194
- var disabledDepth = 0;
5195
- var prevLog;
5196
- var prevInfo;
5197
- var prevWarn;
5198
- var prevError;
5199
- var prevGroup;
5200
- var prevGroupCollapsed;
5201
- var prevGroupEnd;
5310
+ var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
5311
+ function describeBuiltInComponentFrame(name, source, ownerFn) {
5312
+ {
5313
+ var ownerName = null;
5202
5314
 
5203
- function disabledLog() {}
5315
+ if (ownerFn) {
5316
+ ownerName = ownerFn.displayName || ownerFn.name || null;
5317
+ }
5204
5318
 
5205
- disabledLog.__reactDisabledLog = true;
5206
- function disableLogs() {
5207
- {
5208
- if (disabledDepth === 0) {
5209
- /* eslint-disable react-internal/no-production-logging */
5210
- prevLog = console.log;
5211
- prevInfo = console.info;
5212
- prevWarn = console.warn;
5213
- prevError = console.error;
5214
- prevGroup = console.group;
5215
- prevGroupCollapsed = console.groupCollapsed;
5216
- prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
5319
+ return describeComponentFrame(name, source, ownerName);
5320
+ }
5321
+ }
5322
+ var componentFrameCache;
5217
5323
 
5218
- var props = {
5219
- configurable: true,
5220
- enumerable: true,
5221
- value: disabledLog,
5222
- writable: true
5223
- }; // $FlowFixMe Flow thinks console is immutable.
5324
+ {
5325
+ var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
5326
+ componentFrameCache = new PossiblyWeakMap();
5327
+ }
5328
+ var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
5224
5329
 
5225
- Object.defineProperties(console, {
5226
- info: props,
5227
- log: props,
5228
- warn: props,
5229
- error: props,
5230
- group: props,
5231
- groupCollapsed: props,
5232
- groupEnd: props
5233
- });
5234
- /* eslint-enable react-internal/no-production-logging */
5330
+ function describeComponentFrame(name, source, ownerName) {
5331
+ var sourceInfo = "";
5332
+
5333
+ if (source) {
5334
+ var path = source.fileName;
5335
+ var fileName = path.replace(BEFORE_SLASH_RE, ""); // In DEV, include code for a common special case:
5336
+ // prefer "folder/index.js" instead of just "index.js".
5337
+
5338
+ if (/^index\./.test(fileName)) {
5339
+ var match = path.match(BEFORE_SLASH_RE);
5340
+
5341
+ if (match) {
5342
+ var pathBeforeSlash = match[1];
5343
+
5344
+ if (pathBeforeSlash) {
5345
+ var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, "");
5346
+ fileName = folderName + "/" + fileName;
5347
+ }
5348
+ }
5235
5349
  }
5236
5350
 
5237
- disabledDepth++;
5351
+ sourceInfo = " (at " + fileName + ":" + source.lineNumber + ")";
5352
+ } else if (ownerName) {
5353
+ sourceInfo = " (created by " + ownerName + ")";
5238
5354
  }
5239
- }
5240
- function reenableLogs() {
5241
- {
5242
- disabledDepth--;
5243
-
5244
- if (disabledDepth === 0) {
5245
- /* eslint-disable react-internal/no-production-logging */
5246
- var props = {
5247
- configurable: true,
5248
- enumerable: true,
5249
- writable: true
5250
- }; // $FlowFixMe Flow thinks console is immutable.
5251
-
5252
- Object.defineProperties(console, {
5253
- log: Object.assign({}, props, {
5254
- value: prevLog
5255
- }),
5256
- info: Object.assign({}, props, {
5257
- value: prevInfo
5258
- }),
5259
- warn: Object.assign({}, props, {
5260
- value: prevWarn
5261
- }),
5262
- error: Object.assign({}, props, {
5263
- value: prevError
5264
- }),
5265
- group: Object.assign({}, props, {
5266
- value: prevGroup
5267
- }),
5268
- groupCollapsed: Object.assign({}, props, {
5269
- value: prevGroupCollapsed
5270
- }),
5271
- groupEnd: Object.assign({}, props, {
5272
- value: prevGroupEnd
5273
- })
5274
- });
5275
- /* eslint-enable react-internal/no-production-logging */
5276
- }
5277
-
5278
- if (disabledDepth < 0) {
5279
- error(
5280
- "disabledDepth fell below zero. " +
5281
- "This is a bug in React. Please file an issue."
5282
- );
5283
- }
5284
- }
5285
- }
5286
-
5287
- var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
5288
- function describeBuiltInComponentFrame(name, source, ownerFn) {
5289
- {
5290
- var ownerName = null;
5291
-
5292
- if (ownerFn) {
5293
- ownerName = ownerFn.displayName || ownerFn.name || null;
5294
- }
5295
-
5296
- return describeComponentFrame(name, source, ownerName);
5297
- }
5298
- }
5299
- var componentFrameCache;
5300
-
5301
- {
5302
- var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
5303
- componentFrameCache = new PossiblyWeakMap();
5304
- }
5305
- var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
5306
-
5307
- function describeComponentFrame(name, source, ownerName) {
5308
- var sourceInfo = "";
5309
-
5310
- if (source) {
5311
- var path = source.fileName;
5312
- var fileName = path.replace(BEFORE_SLASH_RE, ""); // In DEV, include code for a common special case:
5313
- // prefer "folder/index.js" instead of just "index.js".
5314
-
5315
- if (/^index\./.test(fileName)) {
5316
- var match = path.match(BEFORE_SLASH_RE);
5317
-
5318
- if (match) {
5319
- var pathBeforeSlash = match[1];
5320
-
5321
- if (pathBeforeSlash) {
5322
- var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, "");
5323
- fileName = folderName + "/" + fileName;
5324
- }
5325
- }
5326
- }
5327
-
5328
- sourceInfo = " (at " + fileName + ":" + source.lineNumber + ")";
5329
- } else if (ownerName) {
5330
- sourceInfo = " (created by " + ownerName + ")";
5331
- }
5332
-
5333
- return "\n in " + (name || "Unknown") + sourceInfo;
5355
+
5356
+ return "\n in " + (name || "Unknown") + sourceInfo;
5334
5357
  }
5335
5358
 
5336
5359
  function describeClassComponentFrame(ctor, source, ownerFn) {
@@ -5443,6 +5466,7 @@ function checkPropTypes(typeSpecs, values, location, componentName, element) {
5443
5466
  // This is intentionally an invariant that gets caught. It's the same
5444
5467
  // behavior as without this statement except with a better message.
5445
5468
  if (typeof typeSpecs[typeSpecName] !== "function") {
5469
+ // eslint-disable-next-line react-internal/prod-error-codes
5446
5470
  var err = Error(
5447
5471
  (componentName || "React class") +
5448
5472
  ": " +
@@ -5674,9 +5698,10 @@ function popTopLevelContextObject(fiber) {
5674
5698
 
5675
5699
  function pushTopLevelContextObject(fiber, context, didChange) {
5676
5700
  {
5677
- if (!(contextStackCursor.current === emptyContextObject)) {
5678
- throw Error(
5679
- "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue."
5701
+ if (contextStackCursor.current !== emptyContextObject) {
5702
+ throw new Error(
5703
+ "Unexpected context found on stack. " +
5704
+ "This error is likely caused by a bug in React. Please file an issue."
5680
5705
  );
5681
5706
  }
5682
5707
 
@@ -5715,7 +5740,7 @@ function processChildContext(fiber, type, parentContext) {
5715
5740
 
5716
5741
  for (var contextKey in childContext) {
5717
5742
  if (!(contextKey in childContextTypes)) {
5718
- throw Error(
5743
+ throw new Error(
5719
5744
  (getComponentNameFromFiber(fiber) || "Unknown") +
5720
5745
  '.getChildContext(): key "' +
5721
5746
  contextKey +
@@ -5760,8 +5785,9 @@ function invalidateContextProvider(workInProgress, type, didChange) {
5760
5785
  var instance = workInProgress.stateNode;
5761
5786
 
5762
5787
  if (!instance) {
5763
- throw Error(
5764
- "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue."
5788
+ throw new Error(
5789
+ "Expected to have an instance by this point. " +
5790
+ "This error is likely caused by a bug in React. Please file an issue."
5765
5791
  );
5766
5792
  }
5767
5793
 
@@ -5793,9 +5819,10 @@ function findCurrentUnmaskedContext(fiber) {
5793
5819
  {
5794
5820
  // Currently this is only used with renderSubtreeIntoContainer; not sure if it
5795
5821
  // makes sense elsewhere
5796
- if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) {
5797
- throw Error(
5798
- "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue."
5822
+ if (!isFiberMounted(fiber) || fiber.tag !== ClassComponent) {
5823
+ throw new Error(
5824
+ "Expected subtree parent to be a mounted class component. " +
5825
+ "This error is likely caused by a bug in React. Please file an issue."
5799
5826
  );
5800
5827
  }
5801
5828
 
@@ -5820,17 +5847,28 @@ function findCurrentUnmaskedContext(fiber) {
5820
5847
  node = node.return;
5821
5848
  } while (node !== null);
5822
5849
 
5823
- {
5824
- throw Error(
5825
- "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue."
5826
- );
5827
- }
5850
+ throw new Error(
5851
+ "Found unexpected detached subtree parent. " +
5852
+ "This error is likely caused by a bug in React. Please file an issue."
5853
+ );
5828
5854
  }
5829
5855
  }
5830
5856
 
5831
5857
  var LegacyRoot = 0;
5832
5858
  var ConcurrentRoot = 1;
5833
5859
 
5860
+ /**
5861
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
5862
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
5863
+ */
5864
+ function is(x, y) {
5865
+ return (
5866
+ (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare
5867
+ );
5868
+ }
5869
+
5870
+ var objectIs = typeof Object.is === "function" ? Object.is : is;
5871
+
5834
5872
  var syncQueue = null;
5835
5873
  var includesLegacySyncCallbacks = false;
5836
5874
  var isFlushingSyncQueue = false;
@@ -5900,7 +5938,12 @@ function flushSyncCallbacks() {
5900
5938
  return null;
5901
5939
  }
5902
5940
 
5903
- var ReactVersion = "18.0.0-bd5bf555e-20210823";
5941
+ var ReactVersion = "18.0.0-afcb9cdc9-20211008";
5942
+
5943
+ function markComponentRenderStopped() {}
5944
+ function markComponentErrored(fiber, thrownValue, lanes) {}
5945
+
5946
+ function markComponentSuspended(fiber, wakeable, lanes) {}
5904
5947
 
5905
5948
  var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
5906
5949
  var NoTransition = 0;
@@ -5908,18 +5951,6 @@ function requestCurrentTransition() {
5908
5951
  return ReactCurrentBatchConfig.transition;
5909
5952
  }
5910
5953
 
5911
- /**
5912
- * inlined Object.is polyfill to avoid requiring consumers ship their own
5913
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
5914
- */
5915
- function is(x, y) {
5916
- return (
5917
- (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare
5918
- );
5919
- }
5920
-
5921
- var objectIs = typeof Object.is === "function" ? Object.is : is;
5922
-
5923
5954
  /**
5924
5955
  * Performs equality by iterating through keys on an object and returning false
5925
5956
  * when any key has values which are not strictly equal between the arguments.
@@ -6411,6 +6442,105 @@ var ReactStrictModeWarnings = {
6411
6442
  };
6412
6443
  }
6413
6444
 
6445
+ /*
6446
+ * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
6447
+ * and Temporal.* types. See https://github.com/facebook/react/pull/22064.
6448
+ *
6449
+ * The functions in this module will throw an easier-to-understand,
6450
+ * easier-to-debug exception with a clear errors message message explaining the
6451
+ * problem. (Instead of a confusing exception thrown inside the implementation
6452
+ * of the `value` object).
6453
+ */
6454
+ // $FlowFixMe only called in DEV, so void return is not possible.
6455
+
6456
+ function typeName(value) {
6457
+ {
6458
+ // toStringTag is needed for namespaced types like Temporal.Instant
6459
+ var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
6460
+ var type =
6461
+ (hasToStringTag && value[Symbol.toStringTag]) ||
6462
+ value.constructor.name ||
6463
+ "Object";
6464
+ return type;
6465
+ }
6466
+ } // $FlowFixMe only called in DEV, so void return is not possible.
6467
+
6468
+ function willCoercionThrow(value) {
6469
+ {
6470
+ if (
6471
+ value !== null &&
6472
+ typeof value === "object" &&
6473
+ value.$$typeof === REACT_OPAQUE_ID_TYPE
6474
+ ) {
6475
+ // OpaqueID type is expected to throw, so React will handle it. Not sure if
6476
+ // it's expected that string coercion will throw, but we'll assume it's OK.
6477
+ // See https://github.com/facebook/react/issues/20127.
6478
+ return;
6479
+ }
6480
+
6481
+ try {
6482
+ testStringCoercion(value);
6483
+ return false;
6484
+ } catch (e) {
6485
+ return true;
6486
+ }
6487
+ }
6488
+ }
6489
+
6490
+ function testStringCoercion(value) {
6491
+ // If you ended up here by following an exception call stack, here's what's
6492
+ // happened: you supplied an object or symbol value to React (as a prop, key,
6493
+ // DOM attribute, CSS property, string ref, etc.) and when React tried to
6494
+ // coerce it to a string using `'' + value`, an exception was thrown.
6495
+ //
6496
+ // The most common types that will cause this exception are `Symbol` instances
6497
+ // and Temporal objects like `Temporal.Instant`. But any object that has a
6498
+ // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
6499
+ // exception. (Library authors do this to prevent users from using built-in
6500
+ // numeric operators like `+` or comparison operators like `>=` because custom
6501
+ // methods are needed to perform accurate arithmetic or comparison.)
6502
+ //
6503
+ // To fix the problem, coerce this object or symbol value to a string before
6504
+ // passing it to React. The most reliable way is usually `String(value)`.
6505
+ //
6506
+ // To find which value is throwing, check the browser or debugger console.
6507
+ // Before this exception was thrown, there should be `console.error` output
6508
+ // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
6509
+ // problem and how that type was used: key, atrribute, input value prop, etc.
6510
+ // In most cases, this console output also shows the component and its
6511
+ // ancestor components where the exception happened.
6512
+ //
6513
+ // eslint-disable-next-line react-internal/safe-string-coercion
6514
+ return "" + value;
6515
+ }
6516
+ function checkKeyStringCoercion(value) {
6517
+ {
6518
+ if (willCoercionThrow(value)) {
6519
+ error(
6520
+ "The provided key is an unsupported type %s." +
6521
+ " This value must be coerced to a string before before using it here.",
6522
+ typeName(value)
6523
+ );
6524
+
6525
+ return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
6526
+ }
6527
+ }
6528
+ }
6529
+ function checkPropStringCoercion(value, propName) {
6530
+ {
6531
+ if (willCoercionThrow(value)) {
6532
+ error(
6533
+ "The provided `%s` prop is an unsupported type %s." +
6534
+ " This value must be coerced to a string before before using it here.",
6535
+ propName,
6536
+ typeName(value)
6537
+ );
6538
+
6539
+ return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
6540
+ }
6541
+ }
6542
+ }
6543
+
6414
6544
  function resolveDefaultProps(Component, baseProps) {
6415
6545
  if (Component && Component.defaultProps) {
6416
6546
  // Resolve default props. Taken from ReactElement
@@ -6675,9 +6805,12 @@ function readContext(context) {
6675
6805
  };
6676
6806
 
6677
6807
  if (lastContextDependency === null) {
6678
- if (!(currentlyRenderingFiber !== null)) {
6679
- throw Error(
6680
- "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()."
6808
+ if (currentlyRenderingFiber === null) {
6809
+ throw new Error(
6810
+ "Context can only be read while React is rendering. " +
6811
+ "In classes, you can read it in the render method or getDerivedStateFromProps. " +
6812
+ "In function components, you can read it directly in the function body, but not " +
6813
+ "inside Hooks like useReducer() or useMemo()."
6681
6814
  );
6682
6815
  } // This is the first dependency for this component. Create a new list.
6683
6816
 
@@ -6978,12 +7111,12 @@ function getStateFromUpdate(
6978
7111
 
6979
7112
  {
6980
7113
  if (workInProgress.mode & StrictLegacyMode) {
6981
- disableLogs();
7114
+ setIsStrictModeForDevtools(true);
6982
7115
 
6983
7116
  try {
6984
7117
  payload.call(instance, prevState, nextProps);
6985
7118
  } finally {
6986
- reenableLogs();
7119
+ setIsStrictModeForDevtools(false);
6987
7120
  }
6988
7121
  }
6989
7122
 
@@ -7016,12 +7149,12 @@ function getStateFromUpdate(
7016
7149
 
7017
7150
  {
7018
7151
  if (workInProgress.mode & StrictLegacyMode) {
7019
- disableLogs();
7152
+ setIsStrictModeForDevtools(true);
7020
7153
 
7021
7154
  try {
7022
7155
  _payload.call(instance, prevState, nextProps);
7023
7156
  } finally {
7024
- reenableLogs();
7157
+ setIsStrictModeForDevtools(false);
7025
7158
  }
7026
7159
  }
7027
7160
 
@@ -7245,10 +7378,10 @@ function processUpdateQueue(workInProgress, props, instance, renderLanes) {
7245
7378
  }
7246
7379
 
7247
7380
  function callCallback(callback, context) {
7248
- if (!(typeof callback === "function")) {
7249
- throw Error(
7250
- "Invalid argument passed as callback. Expected a function. Instead received: " +
7251
- callback
7381
+ if (typeof callback !== "function") {
7382
+ throw new Error(
7383
+ "Invalid argument passed as callback. Expected a function. Instead " +
7384
+ ("received: " + callback)
7252
7385
  );
7253
7386
  }
7254
7387
 
@@ -7347,11 +7480,14 @@ var didWarnAboutInvalidateContextType;
7347
7480
  Object.defineProperty(fakeInternalInstance, "_processChildContext", {
7348
7481
  enumerable: false,
7349
7482
  value: function() {
7350
- {
7351
- throw Error(
7352
- "_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal)."
7353
- );
7354
- }
7483
+ throw new Error(
7484
+ "_processChildContext is not available in React 16+. This likely " +
7485
+ "means you have multiple copies of React and are attempting to nest " +
7486
+ "a React 15 tree inside a React 16 tree using " +
7487
+ "unstable_renderSubtreeIntoContainer, which isn't supported. Try " +
7488
+ "to make sure you have only one copy of React (and ideally, switch " +
7489
+ "to ReactDOM.createPortal)."
7490
+ );
7355
7491
  }
7356
7492
  });
7357
7493
  Object.freeze(fakeInternalInstance);
@@ -7368,13 +7504,13 @@ function applyDerivedStateFromProps(
7368
7504
 
7369
7505
  {
7370
7506
  if (workInProgress.mode & StrictLegacyMode) {
7371
- disableLogs();
7507
+ setIsStrictModeForDevtools(true);
7372
7508
 
7373
7509
  try {
7374
7510
  // Invoke the function an extra time to help detect side-effects.
7375
7511
  partialState = getDerivedStateFromProps(nextProps, prevState);
7376
7512
  } finally {
7377
- reenableLogs();
7513
+ setIsStrictModeForDevtools(false);
7378
7514
  }
7379
7515
  }
7380
7516
 
@@ -7486,7 +7622,7 @@ function checkShouldComponentUpdate(
7486
7622
 
7487
7623
  {
7488
7624
  if (workInProgress.mode & StrictLegacyMode) {
7489
- disableLogs();
7625
+ setIsStrictModeForDevtools(true);
7490
7626
 
7491
7627
  try {
7492
7628
  // Invoke the function an extra time to help detect side-effects.
@@ -7496,7 +7632,7 @@ function checkShouldComponentUpdate(
7496
7632
  nextContext
7497
7633
  );
7498
7634
  } finally {
7499
- reenableLogs();
7635
+ setIsStrictModeForDevtools(false);
7500
7636
  }
7501
7637
  }
7502
7638
 
@@ -7820,12 +7956,12 @@ function constructClassInstance(workInProgress, ctor, props) {
7820
7956
 
7821
7957
  {
7822
7958
  if (workInProgress.mode & StrictLegacyMode) {
7823
- disableLogs();
7959
+ setIsStrictModeForDevtools(true);
7824
7960
 
7825
7961
  try {
7826
7962
  instance = new ctor(props, context); // eslint-disable-line no-new
7827
7963
  } finally {
7828
- reenableLogs();
7964
+ setIsStrictModeForDevtools(false);
7829
7965
  }
7830
7966
  }
7831
7967
  }
@@ -8431,9 +8567,10 @@ var warnForMissingKey = function(child, returnFiber) {};
8431
8567
  return;
8432
8568
  }
8433
8569
 
8434
- if (!(typeof child._store === "object")) {
8435
- throw Error(
8436
- "React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue."
8570
+ if (typeof child._store !== "object") {
8571
+ throw new Error(
8572
+ "React Component in warnForMissingKey should have a _store. " +
8573
+ "This error is likely caused by a bug in React. Please file an issue."
8437
8574
  );
8438
8575
  }
8439
8576
 
@@ -8502,9 +8639,12 @@ function coerceRef(returnFiber, current, element) {
8502
8639
  if (owner) {
8503
8640
  var ownerFiber = owner;
8504
8641
 
8505
- if (!(ownerFiber.tag === ClassComponent)) {
8506
- throw Error(
8507
- "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref"
8642
+ if (ownerFiber.tag !== ClassComponent) {
8643
+ throw new Error(
8644
+ "Function components cannot have string refs. " +
8645
+ "We recommend using useRef() instead. " +
8646
+ "Learn more about using refs safely here: " +
8647
+ "https://reactjs.org/link/strict-mode-string-ref"
8508
8648
  );
8509
8649
  }
8510
8650
 
@@ -8512,11 +8652,18 @@ function coerceRef(returnFiber, current, element) {
8512
8652
  }
8513
8653
 
8514
8654
  if (!inst) {
8515
- throw Error(
8655
+ throw new Error(
8516
8656
  "Missing owner for string ref " +
8517
8657
  mixedRef +
8518
- ". This error is likely caused by a bug in React. Please file an issue."
8658
+ ". This error is likely caused by a " +
8659
+ "bug in React. Please file an issue."
8519
8660
  );
8661
+ } // Assigning this to a const so Flow knows it won't change in the closure
8662
+
8663
+ var resolvedInst = inst;
8664
+
8665
+ {
8666
+ checkPropStringCoercion(mixedRef, "ref");
8520
8667
  }
8521
8668
 
8522
8669
  var stringRef = "" + mixedRef; // Check if previous string ref matches new string ref
@@ -8531,11 +8678,11 @@ function coerceRef(returnFiber, current, element) {
8531
8678
  }
8532
8679
 
8533
8680
  var ref = function(value) {
8534
- var refs = inst.refs;
8681
+ var refs = resolvedInst.refs;
8535
8682
 
8536
8683
  if (refs === emptyRefsObject) {
8537
8684
  // This is a lazy pooled frozen object, so we need to initialize.
8538
- refs = inst.refs = {};
8685
+ refs = resolvedInst.refs = {};
8539
8686
  }
8540
8687
 
8541
8688
  if (value === null) {
@@ -8548,17 +8695,22 @@ function coerceRef(returnFiber, current, element) {
8548
8695
  ref._stringRef = stringRef;
8549
8696
  return ref;
8550
8697
  } else {
8551
- if (!(typeof mixedRef === "string")) {
8552
- throw Error(
8698
+ if (typeof mixedRef !== "string") {
8699
+ throw new Error(
8553
8700
  "Expected ref to be a function, a string, an object returned by React.createRef(), or null."
8554
8701
  );
8555
8702
  }
8556
8703
 
8557
8704
  if (!element._owner) {
8558
- throw Error(
8705
+ throw new Error(
8559
8706
  "Element ref was specified as a string (" +
8560
8707
  mixedRef +
8561
- ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://reactjs.org/link/refs-must-have-owner for more information."
8708
+ ") but no owner was set. This could happen for one of" +
8709
+ " the following reasons:\n" +
8710
+ "1. You may be adding a ref to a function component\n" +
8711
+ "2. You may be adding a ref to a component that was not created inside a component's render method\n" +
8712
+ "3. You have multiple copies of React loaded\n" +
8713
+ "See https://reactjs.org/link/refs-must-have-owner for more information."
8562
8714
  );
8563
8715
  }
8564
8716
  }
@@ -8569,16 +8721,15 @@ function coerceRef(returnFiber, current, element) {
8569
8721
 
8570
8722
  function throwOnInvalidObjectType(returnFiber, newChild) {
8571
8723
  var childString = Object.prototype.toString.call(newChild);
8572
-
8573
- {
8574
- throw Error(
8575
- "Objects are not valid as a React child (found: " +
8576
- (childString === "[object Object]"
8577
- ? "object with keys {" + Object.keys(newChild).join(", ") + "}"
8578
- : childString) +
8579
- "). If you meant to render a collection of children, use an array instead."
8580
- );
8581
- }
8724
+ throw new Error(
8725
+ "Objects are not valid as a React child (found: " +
8726
+ (childString === "[object Object]"
8727
+ ? "object with keys {" + Object.keys(newChild).join(", ") + "}"
8728
+ : childString) +
8729
+ "). " +
8730
+ "If you meant to render a collection of children, use an array " +
8731
+ "instead."
8732
+ );
8582
8733
  }
8583
8734
 
8584
8735
  function warnOnFunctionType(returnFiber) {
@@ -9194,9 +9345,10 @@ function ChildReconciler(shouldTrackSideEffects) {
9194
9345
  // but using the iterator instead.
9195
9346
  var iteratorFn = getIteratorFn(newChildrenIterable);
9196
9347
 
9197
- if (!(typeof iteratorFn === "function")) {
9198
- throw Error(
9199
- "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue."
9348
+ if (typeof iteratorFn !== "function") {
9349
+ throw new Error(
9350
+ "An object is not an iterable. This error is likely caused by a bug in " +
9351
+ "React. Please file an issue."
9200
9352
  );
9201
9353
  }
9202
9354
 
@@ -9248,8 +9400,8 @@ function ChildReconciler(shouldTrackSideEffects) {
9248
9400
 
9249
9401
  var newChildren = iteratorFn.call(newChildrenIterable);
9250
9402
 
9251
- if (!(newChildren != null)) {
9252
- throw Error("An iterable object provided no iterator.");
9403
+ if (newChildren == null) {
9404
+ throw new Error("An iterable object provided no iterator.");
9253
9405
  }
9254
9406
 
9255
9407
  var resultingFirstChild = null;
@@ -9626,8 +9778,8 @@ function ChildReconciler(shouldTrackSideEffects) {
9626
9778
  var reconcileChildFibers = ChildReconciler(true);
9627
9779
  var mountChildFibers = ChildReconciler(false);
9628
9780
  function cloneChildFibers(current, workInProgress) {
9629
- if (!(current === null || workInProgress.child === current.child)) {
9630
- throw Error("Resuming work not yet implemented.");
9781
+ if (current !== null && workInProgress.child !== current.child) {
9782
+ throw new Error("Resuming work not yet implemented.");
9631
9783
  }
9632
9784
 
9633
9785
  if (workInProgress.child === null) {
@@ -9666,9 +9818,10 @@ var contextFiberStackCursor = createCursor(NO_CONTEXT);
9666
9818
  var rootInstanceStackCursor = createCursor(NO_CONTEXT);
9667
9819
 
9668
9820
  function requiredContext(c) {
9669
- if (!(c !== NO_CONTEXT)) {
9670
- throw Error(
9671
- "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue."
9821
+ if (c === NO_CONTEXT) {
9822
+ throw new Error(
9823
+ "Expected host context to exist. This error is likely caused by a bug " +
9824
+ "in React. Please file an issue."
9672
9825
  );
9673
9826
  }
9674
9827
 
@@ -9854,19 +10007,22 @@ function findFirstSuspended(row) {
9854
10007
  }
9855
10008
 
9856
10009
  var NoFlags$1 =
9857
- /* */
10010
+ /* */
9858
10011
  0; // Represents whether effect should fire.
9859
10012
 
9860
10013
  var HasEffect =
9861
10014
  /* */
9862
10015
  1; // Represents the phase in which the effect (not the clean-up) fires.
9863
10016
 
10017
+ var Insertion =
10018
+ /* */
10019
+ 2;
9864
10020
  var Layout =
9865
10021
  /* */
9866
- 2;
10022
+ 4;
9867
10023
  var Passive$1 =
9868
10024
  /* */
9869
- 4;
10025
+ 8;
9870
10026
 
9871
10027
  var isHydrating = false;
9872
10028
 
@@ -9882,21 +10038,19 @@ function prepareToHydrateHostInstance(
9882
10038
  hostContext
9883
10039
  ) {
9884
10040
  {
9885
- {
9886
- throw Error(
9887
- "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."
9888
- );
9889
- }
10041
+ throw new Error(
10042
+ "Expected prepareToHydrateHostInstance() to never be called. " +
10043
+ "This error is likely caused by a bug in React. Please file an issue."
10044
+ );
9890
10045
  }
9891
10046
  }
9892
10047
 
9893
10048
  function prepareToHydrateHostTextInstance(fiber) {
9894
10049
  {
9895
- {
9896
- throw Error(
9897
- "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."
9898
- );
9899
- }
10050
+ throw new Error(
10051
+ "Expected prepareToHydrateHostTextInstance() to never be called. " +
10052
+ "This error is likely caused by a bug in React. Please file an issue."
10053
+ );
9900
10054
  }
9901
10055
  var shouldUpdate = hydrateTextInstance();
9902
10056
  }
@@ -9973,6 +10127,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
9973
10127
  ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig;
9974
10128
  var didWarnAboutMismatchedHooksForComponent;
9975
10129
  var didWarnAboutUseOpaqueIdentifier;
10130
+ var didWarnUncachedGetSnapshot;
9976
10131
 
9977
10132
  {
9978
10133
  didWarnAboutUseOpaqueIdentifier = {};
@@ -10097,11 +10252,14 @@ function warnOnHookMismatchInDev(currentHookName) {
10097
10252
  }
10098
10253
 
10099
10254
  function throwInvalidHookError() {
10100
- {
10101
- throw Error(
10102
- "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem."
10103
- );
10104
- }
10255
+ throw new Error(
10256
+ "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for" +
10257
+ " one of the following reasons:\n" +
10258
+ "1. You might have mismatching versions of React and the renderer (such as React DOM)\n" +
10259
+ "2. You might be breaking the Rules of Hooks\n" +
10260
+ "3. You might have more than one copy of React in the same app\n" +
10261
+ "See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem."
10262
+ );
10105
10263
  }
10106
10264
 
10107
10265
  function areHookInputsEqual(nextDeps, prevDeps) {
@@ -10209,9 +10367,10 @@ function renderWithHooks(
10209
10367
  do {
10210
10368
  didScheduleRenderPhaseUpdateDuringThisPass = false;
10211
10369
 
10212
- if (!(numberOfReRenders < RE_RENDER_LIMIT)) {
10213
- throw Error(
10214
- "Too many re-renders. React limits the number of renders to prevent an infinite loop."
10370
+ if (numberOfReRenders >= RE_RENDER_LIMIT) {
10371
+ throw new Error(
10372
+ "Too many re-renders. React limits the number of renders to prevent " +
10373
+ "an infinite loop."
10215
10374
  );
10216
10375
  }
10217
10376
 
@@ -10277,9 +10436,10 @@ function renderWithHooks(
10277
10436
 
10278
10437
  didScheduleRenderPhaseUpdate = false;
10279
10438
 
10280
- if (!!didRenderTooFewHooks) {
10281
- throw Error(
10282
- "Rendered fewer hooks than expected. This may be caused by an accidental early return statement."
10439
+ if (didRenderTooFewHooks) {
10440
+ throw new Error(
10441
+ "Rendered fewer hooks than expected. This may be caused by an accidental " +
10442
+ "early return statement."
10283
10443
  );
10284
10444
  }
10285
10445
 
@@ -10401,8 +10561,8 @@ function updateWorkInProgressHook() {
10401
10561
  currentHook = nextCurrentHook;
10402
10562
  } else {
10403
10563
  // Clone from the current hook.
10404
- if (!(nextCurrentHook !== null)) {
10405
- throw Error("Rendered more hooks than during the previous render.");
10564
+ if (nextCurrentHook === null) {
10565
+ throw new Error("Rendered more hooks than during the previous render.");
10406
10566
  }
10407
10567
 
10408
10568
  currentHook = nextCurrentHook;
@@ -10428,7 +10588,8 @@ function updateWorkInProgressHook() {
10428
10588
 
10429
10589
  function createFunctionComponentUpdateQueue() {
10430
10590
  return {
10431
- lastEffect: null
10591
+ lastEffect: null,
10592
+ stores: null
10432
10593
  };
10433
10594
  }
10434
10595
 
@@ -10448,15 +10609,16 @@ function mountReducer(reducer, initialArg, init) {
10448
10609
  }
10449
10610
 
10450
10611
  hook.memoizedState = hook.baseState = initialState;
10451
- var queue = (hook.queue = {
10612
+ var queue = {
10452
10613
  pending: null,
10453
10614
  interleaved: null,
10454
10615
  lanes: NoLanes,
10455
10616
  dispatch: null,
10456
10617
  lastRenderedReducer: reducer,
10457
10618
  lastRenderedState: initialState
10458
- });
10459
- var dispatch = (queue.dispatch = dispatchAction.bind(
10619
+ };
10620
+ hook.queue = queue;
10621
+ var dispatch = (queue.dispatch = dispatchReducerAction.bind(
10460
10622
  null,
10461
10623
  currentlyRenderingFiber$1,
10462
10624
  queue
@@ -10468,8 +10630,8 @@ function updateReducer(reducer, initialArg, init) {
10468
10630
  var hook = updateWorkInProgressHook();
10469
10631
  var queue = hook.queue;
10470
10632
 
10471
- if (!(queue !== null)) {
10472
- throw Error(
10633
+ if (queue === null) {
10634
+ throw new Error(
10473
10635
  "Should have a queue. This is likely a bug in React. Please file an issue."
10474
10636
  );
10475
10637
  }
@@ -10526,7 +10688,7 @@ function updateReducer(reducer, initialArg, init) {
10526
10688
  var clone = {
10527
10689
  lane: updateLane,
10528
10690
  action: update.action,
10529
- eagerReducer: update.eagerReducer,
10691
+ hasEagerState: update.hasEagerState,
10530
10692
  eagerState: update.eagerState,
10531
10693
  next: null
10532
10694
  };
@@ -10554,16 +10716,16 @@ function updateReducer(reducer, initialArg, init) {
10554
10716
  // this will never be skipped by the check above.
10555
10717
  lane: NoLane,
10556
10718
  action: update.action,
10557
- eagerReducer: update.eagerReducer,
10719
+ hasEagerState: update.hasEagerState,
10558
10720
  eagerState: update.eagerState,
10559
10721
  next: null
10560
10722
  };
10561
10723
  newBaseQueueLast = newBaseQueueLast.next = _clone;
10562
10724
  } // Process this update.
10563
10725
 
10564
- if (update.eagerReducer === reducer) {
10565
- // If this update was processed eagerly, and its reducer matches the
10566
- // current reducer, we can use the eagerly computed state.
10726
+ if (update.hasEagerState) {
10727
+ // If this update is a state update (not a reducer) and was processed eagerly,
10728
+ // we can use the eagerly computed state
10567
10729
  newState = update.eagerState;
10568
10730
  } else {
10569
10731
  var action = update.action;
@@ -10621,8 +10783,8 @@ function rerenderReducer(reducer, initialArg, init) {
10621
10783
  var hook = updateWorkInProgressHook();
10622
10784
  var queue = hook.queue;
10623
10785
 
10624
- if (!(queue !== null)) {
10625
- throw Error(
10786
+ if (queue === null) {
10787
+ throw new Error(
10626
10788
  "Should have a queue. This is likely a bug in React. Please file an issue."
10627
10789
  );
10628
10790
  }
@@ -10742,56 +10904,20 @@ function readFromUnsubscribedMutableSource(root, source, getSnapshot) {
10742
10904
  // the synchronous retry, it will block interleaved mutations, so we should
10743
10905
  // get a consistent read. Therefore, the following error should never be
10744
10906
  // visible to the user.
10745
- //
10746
- // If it were to become visible to the user, it suggests one of two things:
10747
- // a bug in React, or (more likely), a mutation during the render phase that
10748
- // caused the second re-render attempt to be different from the first.
10749
- //
10750
- // We know it's the second case if the logs are currently disabled. So in
10751
- // dev, we can present a more accurate error message.
10752
-
10753
- {
10754
- // eslint-disable-next-line react-internal/no-production-logging
10755
- if (console.log.__reactDisabledLog) {
10756
- // If the logs are disabled, this is the dev-only double render. This is
10757
- // only reachable if there was a mutation during render. Show a helpful
10758
- // error message.
10759
- //
10760
- // Something interesting to note: because we only double render in
10761
- // development, this error will never happen during production. This is
10762
- // actually true of all errors that occur during a double render,
10763
- // because if the first render had thrown, we would have exited the
10764
- // begin phase without double rendering. We should consider suppressing
10765
- // any error from a double render (with a warning) to more closely match
10766
- // the production behavior.
10767
- var componentName = getComponentNameFromFiber(
10768
- currentlyRenderingFiber$1
10769
- );
10770
-
10771
- {
10772
- throw Error(
10773
- "A mutable source was mutated while the " +
10774
- componentName +
10775
- " component was rendering. This is not supported. Move any mutations into event handlers or effects."
10776
- );
10777
- }
10778
- }
10779
- } // We expect this error not to be thrown during the synchronous retry,
10907
+ // We expect this error not to be thrown during the synchronous retry,
10780
10908
  // because we blocked interleaved mutations.
10781
10909
 
10782
- {
10783
- throw Error(
10784
- "Cannot read from mutable source during the current render without tearing. This may be a bug in React. Please file an issue."
10785
- );
10786
- }
10910
+ throw new Error(
10911
+ "Cannot read from mutable source during the current render without tearing. This may be a bug in React. Please file an issue."
10912
+ );
10787
10913
  }
10788
10914
  }
10789
10915
 
10790
10916
  function useMutableSource(hook, source, getSnapshot, subscribe) {
10791
10917
  var root = getWorkInProgressRoot();
10792
10918
 
10793
- if (!(root !== null)) {
10794
- throw Error(
10919
+ if (root === null) {
10920
+ throw new Error(
10795
10921
  "Expected a work-in-progress root. This is a bug in React. Please file an issue."
10796
10922
  );
10797
10923
  }
@@ -10923,7 +11049,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) {
10923
11049
  lastRenderedReducer: basicStateReducer,
10924
11050
  lastRenderedState: snapshot
10925
11051
  };
10926
- newQueue.dispatch = setSnapshot = dispatchAction.bind(
11052
+ newQueue.dispatch = setSnapshot = dispatchSetState.bind(
10927
11053
  null,
10928
11054
  currentlyRenderingFiber$1,
10929
11055
  newQueue
@@ -10955,42 +11081,244 @@ function updateMutableSource(source, getSnapshot, subscribe) {
10955
11081
  return useMutableSource(hook, source, getSnapshot, subscribe);
10956
11082
  }
10957
11083
 
10958
- function mountState(initialState) {
11084
+ function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
11085
+ var fiber = currentlyRenderingFiber$1;
10959
11086
  var hook = mountWorkInProgressHook();
11087
+ var nextSnapshot;
10960
11088
 
10961
- if (typeof initialState === "function") {
10962
- // $FlowFixMe: Flow doesn't like mixed types
10963
- initialState = initialState();
10964
- }
11089
+ {
11090
+ nextSnapshot = getSnapshot();
10965
11091
 
10966
- hook.memoizedState = hook.baseState = initialState;
10967
- var queue = (hook.queue = {
10968
- pending: null,
10969
- interleaved: null,
10970
- lanes: NoLanes,
10971
- dispatch: null,
10972
- lastRenderedReducer: basicStateReducer,
10973
- lastRenderedState: initialState
10974
- });
10975
- var dispatch = (queue.dispatch = dispatchAction.bind(
10976
- null,
10977
- currentlyRenderingFiber$1,
10978
- queue
10979
- ));
10980
- return [hook.memoizedState, dispatch];
10981
- }
11092
+ {
11093
+ if (!didWarnUncachedGetSnapshot) {
11094
+ if (nextSnapshot !== getSnapshot()) {
11095
+ error(
11096
+ "The result of getSnapshot should be cached to avoid an infinite loop"
11097
+ );
10982
11098
 
10983
- function updateState(initialState) {
10984
- return updateReducer(basicStateReducer);
10985
- }
11099
+ didWarnUncachedGetSnapshot = true;
11100
+ }
11101
+ }
11102
+ } // Unless we're rendering a blocking lane, schedule a consistency check.
11103
+ // Right before committing, we will walk the tree and check if any of the
11104
+ // stores were mutated.
11105
+ //
11106
+ // We won't do this if we're hydrating server-rendered content, because if
11107
+ // the content is stale, it's already visible anyway. Instead we'll patch
11108
+ // it up in a passive effect.
10986
11109
 
10987
- function rerenderState(initialState) {
10988
- return rerenderReducer(basicStateReducer);
10989
- }
11110
+ var root = getWorkInProgressRoot();
10990
11111
 
10991
- function pushEffect(tag, create, destroy, deps) {
10992
- var effect = {
10993
- tag: tag,
11112
+ if (root === null) {
11113
+ throw new Error(
11114
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
11115
+ );
11116
+ }
11117
+
11118
+ if (!includesBlockingLane(root, renderLanes)) {
11119
+ pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot);
11120
+ }
11121
+ } // Read the current snapshot from the store on every render. This breaks the
11122
+ // normal rules of React, and only works because store updates are
11123
+ // always synchronous.
11124
+
11125
+ hook.memoizedState = nextSnapshot;
11126
+ var inst = {
11127
+ value: nextSnapshot,
11128
+ getSnapshot: getSnapshot
11129
+ };
11130
+ hook.queue = inst; // Schedule an effect to subscribe to the store.
11131
+
11132
+ mountEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [subscribe]); // Schedule an effect to update the mutable instance fields. We will update
11133
+ // this whenever subscribe, getSnapshot, or value changes. Because there's no
11134
+ // clean-up function, and we track the deps correctly, we can call pushEffect
11135
+ // directly, without storing any additional state. For the same reason, we
11136
+ // don't need to set a static flag, either.
11137
+ // TODO: We can move this to the passive phase once we add a pre-commit
11138
+ // consistency check. See the next comment.
11139
+
11140
+ fiber.flags |= Passive;
11141
+ pushEffect(
11142
+ HasEffect | Passive$1,
11143
+ updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot),
11144
+ undefined,
11145
+ null
11146
+ );
11147
+ return nextSnapshot;
11148
+ }
11149
+
11150
+ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
11151
+ var fiber = currentlyRenderingFiber$1;
11152
+ var hook = updateWorkInProgressHook(); // Read the current snapshot from the store on every render. This breaks the
11153
+ // normal rules of React, and only works because store updates are
11154
+ // always synchronous.
11155
+
11156
+ var nextSnapshot = getSnapshot();
11157
+
11158
+ {
11159
+ if (!didWarnUncachedGetSnapshot) {
11160
+ if (nextSnapshot !== getSnapshot()) {
11161
+ error(
11162
+ "The result of getSnapshot should be cached to avoid an infinite loop"
11163
+ );
11164
+
11165
+ didWarnUncachedGetSnapshot = true;
11166
+ }
11167
+ }
11168
+ }
11169
+
11170
+ var prevSnapshot = hook.memoizedState;
11171
+ var snapshotChanged = !objectIs(prevSnapshot, nextSnapshot);
11172
+
11173
+ if (snapshotChanged) {
11174
+ hook.memoizedState = nextSnapshot;
11175
+ markWorkInProgressReceivedUpdate();
11176
+ }
11177
+
11178
+ var inst = hook.queue;
11179
+ updateEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [
11180
+ subscribe
11181
+ ]); // Whenever getSnapshot or subscribe changes, we need to check in the
11182
+ // commit phase if there was an interleaved mutation. In concurrent mode
11183
+ // this can happen all the time, but even in synchronous mode, an earlier
11184
+ // effect may have mutated the store.
11185
+
11186
+ if (
11187
+ inst.getSnapshot !== getSnapshot ||
11188
+ snapshotChanged || // Check if the susbcribe function changed. We can save some memory by
11189
+ // checking whether we scheduled a subscription effect above.
11190
+ (workInProgressHook !== null &&
11191
+ workInProgressHook.memoizedState.tag & HasEffect)
11192
+ ) {
11193
+ fiber.flags |= Passive;
11194
+ pushEffect(
11195
+ HasEffect | Passive$1,
11196
+ updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot),
11197
+ undefined,
11198
+ null
11199
+ ); // Unless we're rendering a blocking lane, schedule a consistency check.
11200
+ // Right before committing, we will walk the tree and check if any of the
11201
+ // stores were mutated.
11202
+
11203
+ var root = getWorkInProgressRoot();
11204
+
11205
+ if (root === null) {
11206
+ throw new Error(
11207
+ "Expected a work-in-progress root. This is a bug in React. Please file an issue."
11208
+ );
11209
+ }
11210
+
11211
+ if (!includesBlockingLane(root, renderLanes)) {
11212
+ pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot);
11213
+ }
11214
+ }
11215
+
11216
+ return nextSnapshot;
11217
+ }
11218
+
11219
+ function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) {
11220
+ fiber.flags |= StoreConsistency;
11221
+ var check = {
11222
+ getSnapshot: getSnapshot,
11223
+ value: renderedSnapshot
11224
+ };
11225
+ var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue;
11226
+
11227
+ if (componentUpdateQueue === null) {
11228
+ componentUpdateQueue = createFunctionComponentUpdateQueue();
11229
+ currentlyRenderingFiber$1.updateQueue = componentUpdateQueue;
11230
+ componentUpdateQueue.stores = [check];
11231
+ } else {
11232
+ var stores = componentUpdateQueue.stores;
11233
+
11234
+ if (stores === null) {
11235
+ componentUpdateQueue.stores = [check];
11236
+ } else {
11237
+ stores.push(check);
11238
+ }
11239
+ }
11240
+ }
11241
+
11242
+ function updateStoreInstance(fiber, inst, nextSnapshot, getSnapshot) {
11243
+ // These are updated in the passive phase
11244
+ inst.value = nextSnapshot;
11245
+ inst.getSnapshot = getSnapshot; // Something may have been mutated in between render and commit. This could
11246
+ // have been in an event that fired before the passive effects, or it could
11247
+ // have been in a layout effect. In that case, we would have used the old
11248
+ // snapsho and getSnapshot values to bail out. We need to check one more time.
11249
+
11250
+ if (checkIfSnapshotChanged(inst)) {
11251
+ // Force a re-render.
11252
+ forceStoreRerender(fiber);
11253
+ }
11254
+ }
11255
+
11256
+ function subscribeToStore(fiber, inst, subscribe) {
11257
+ var handleStoreChange = function() {
11258
+ // The store changed. Check if the snapshot changed since the last time we
11259
+ // read from the store.
11260
+ if (checkIfSnapshotChanged(inst)) {
11261
+ // Force a re-render.
11262
+ forceStoreRerender(fiber);
11263
+ }
11264
+ }; // Subscribe to the store and return a clean-up function.
11265
+
11266
+ return subscribe(handleStoreChange);
11267
+ }
11268
+
11269
+ function checkIfSnapshotChanged(inst) {
11270
+ var latestGetSnapshot = inst.getSnapshot;
11271
+ var prevValue = inst.value;
11272
+
11273
+ try {
11274
+ var nextValue = latestGetSnapshot();
11275
+ return !objectIs(prevValue, nextValue);
11276
+ } catch (error) {
11277
+ return true;
11278
+ }
11279
+ }
11280
+
11281
+ function forceStoreRerender(fiber) {
11282
+ scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
11283
+ }
11284
+
11285
+ function mountState(initialState) {
11286
+ var hook = mountWorkInProgressHook();
11287
+
11288
+ if (typeof initialState === "function") {
11289
+ // $FlowFixMe: Flow doesn't like mixed types
11290
+ initialState = initialState();
11291
+ }
11292
+
11293
+ hook.memoizedState = hook.baseState = initialState;
11294
+ var queue = {
11295
+ pending: null,
11296
+ interleaved: null,
11297
+ lanes: NoLanes,
11298
+ dispatch: null,
11299
+ lastRenderedReducer: basicStateReducer,
11300
+ lastRenderedState: initialState
11301
+ };
11302
+ hook.queue = queue;
11303
+ var dispatch = (queue.dispatch = dispatchSetState.bind(
11304
+ null,
11305
+ currentlyRenderingFiber$1,
11306
+ queue
11307
+ ));
11308
+ return [hook.memoizedState, dispatch];
11309
+ }
11310
+
11311
+ function updateState(initialState) {
11312
+ return updateReducer(basicStateReducer);
11313
+ }
11314
+
11315
+ function rerenderState(initialState) {
11316
+ return rerenderReducer(basicStateReducer);
11317
+ }
11318
+
11319
+ function pushEffect(tag, create, destroy, deps) {
11320
+ var effect = {
11321
+ tag: tag,
10994
11322
  create: create,
10995
11323
  destroy: destroy,
10996
11324
  deps: deps,
@@ -11093,6 +11421,14 @@ function updateEffect(create, deps) {
11093
11421
  return updateEffectImpl(Passive, Passive$1, create, deps);
11094
11422
  }
11095
11423
 
11424
+ function mountInsertionEffect(create, deps) {
11425
+ return mountEffectImpl(Update, Insertion, create, deps);
11426
+ }
11427
+
11428
+ function updateInsertionEffect(create, deps) {
11429
+ return updateEffectImpl(Update, Insertion, create, deps);
11430
+ }
11431
+
11096
11432
  function mountLayoutEffect(create, deps) {
11097
11433
  var fiberFlags = Update;
11098
11434
 
@@ -11328,6 +11664,26 @@ function startTransition(setPending, callback) {
11328
11664
  } finally {
11329
11665
  setCurrentUpdatePriority(previousPriority);
11330
11666
  ReactCurrentBatchConfig$1.transition = prevTransition;
11667
+
11668
+ {
11669
+ if (
11670
+ prevTransition !== 1 &&
11671
+ warnOnSubscriptionInsideStartTransition &&
11672
+ ReactCurrentBatchConfig$1._updatedFibers
11673
+ ) {
11674
+ var updatedFibersCount = ReactCurrentBatchConfig$1._updatedFibers.size;
11675
+
11676
+ if (updatedFibersCount > 10) {
11677
+ warn(
11678
+ "Detected a large number of updates inside startTransition. " +
11679
+ "If this is due to a subscription please re-write it to use React provided hooks. " +
11680
+ "Otherwise concurrent mode guarantees are off the table."
11681
+ );
11682
+ }
11683
+
11684
+ ReactCurrentBatchConfig$1._updatedFibers.clear();
11685
+ }
11686
+ }
11331
11687
  }
11332
11688
  }
11333
11689
 
@@ -11408,7 +11764,7 @@ function rerenderOpaqueIdentifier() {
11408
11764
  return id;
11409
11765
  }
11410
11766
 
11411
- function dispatchAction(fiber, queue, action) {
11767
+ function dispatchReducerAction(fiber, queue, action) {
11412
11768
  {
11413
11769
  if (typeof arguments[3] === "function") {
11414
11770
  error(
@@ -11419,65 +11775,54 @@ function dispatchAction(fiber, queue, action) {
11419
11775
  }
11420
11776
  }
11421
11777
 
11422
- var eventTime = requestEventTime();
11423
11778
  var lane = requestUpdateLane(fiber);
11424
11779
  var update = {
11425
11780
  lane: lane,
11426
11781
  action: action,
11427
- eagerReducer: null,
11782
+ hasEagerState: false,
11428
11783
  eagerState: null,
11429
11784
  next: null
11430
11785
  };
11431
- var alternate = fiber.alternate;
11432
-
11433
- if (
11434
- fiber === currentlyRenderingFiber$1 ||
11435
- (alternate !== null && alternate === currentlyRenderingFiber$1)
11436
- ) {
11437
- // This is a render phase update. Stash it in a lazily-created map of
11438
- // queue -> linked list of updates. After this render pass, we'll restart
11439
- // and apply the stashed updates on top of the work-in-progress hook.
11440
- didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true;
11441
- var pending = queue.pending;
11442
-
11443
- if (pending === null) {
11444
- // This is the first update. Create a circular list.
11445
- update.next = update;
11446
- } else {
11447
- update.next = pending.next;
11448
- pending.next = update;
11449
- }
11450
11786
 
11451
- queue.pending = update;
11787
+ if (isRenderPhaseUpdate(fiber)) {
11788
+ enqueueRenderPhaseUpdate(queue, update);
11452
11789
  } else {
11453
- if (isInterleavedUpdate(fiber)) {
11454
- var interleaved = queue.interleaved;
11790
+ enqueueUpdate$1(fiber, queue, update);
11455
11791
 
11456
- if (interleaved === null) {
11457
- // This is the first update. Create a circular list.
11458
- update.next = update; // At the end of the current render, this queue's interleaved updates will
11459
- // be transferred to the pending queue.
11792
+ var eventTime = requestEventTime();
11793
+ var root = scheduleUpdateOnFiber(fiber, lane, eventTime);
11460
11794
 
11461
- pushInterleavedQueue(queue);
11462
- } else {
11463
- update.next = interleaved.next;
11464
- interleaved.next = update;
11465
- }
11795
+ if (root !== null) {
11796
+ entangleTransitionUpdate(root, queue, lane);
11797
+ }
11798
+ }
11799
+ }
11466
11800
 
11467
- queue.interleaved = update;
11468
- } else {
11469
- var _pending = queue.pending;
11801
+ function dispatchSetState(fiber, queue, action) {
11802
+ {
11803
+ if (typeof arguments[3] === "function") {
11804
+ error(
11805
+ "State updates from the useState() and useReducer() Hooks don't support the " +
11806
+ "second callback argument. To execute a side effect after " +
11807
+ "rendering, declare it in the component body with useEffect()."
11808
+ );
11809
+ }
11810
+ }
11470
11811
 
11471
- if (_pending === null) {
11472
- // This is the first update. Create a circular list.
11473
- update.next = update;
11474
- } else {
11475
- update.next = _pending.next;
11476
- _pending.next = update;
11477
- }
11812
+ var lane = requestUpdateLane(fiber);
11813
+ var update = {
11814
+ lane: lane,
11815
+ action: action,
11816
+ hasEagerState: false,
11817
+ eagerState: null,
11818
+ next: null
11819
+ };
11478
11820
 
11479
- queue.pending = update;
11480
- }
11821
+ if (isRenderPhaseUpdate(fiber)) {
11822
+ enqueueRenderPhaseUpdate(queue, update);
11823
+ } else {
11824
+ enqueueUpdate$1(fiber, queue, update);
11825
+ var alternate = fiber.alternate;
11481
11826
 
11482
11827
  if (
11483
11828
  fiber.lanes === NoLanes &&
@@ -11503,7 +11848,7 @@ function dispatchAction(fiber, queue, action) {
11503
11848
  // time we enter the render phase, then the eager state can be used
11504
11849
  // without calling the reducer again.
11505
11850
 
11506
- update.eagerReducer = lastRenderedReducer;
11851
+ update.hasEagerState = true;
11507
11852
  update.eagerState = eagerState;
11508
11853
 
11509
11854
  if (objectIs(eagerState, currentState)) {
@@ -11523,24 +11868,88 @@ function dispatchAction(fiber, queue, action) {
11523
11868
  }
11524
11869
  }
11525
11870
 
11871
+ var eventTime = requestEventTime();
11526
11872
  var root = scheduleUpdateOnFiber(fiber, lane, eventTime);
11527
11873
 
11528
- if (isTransitionLane(lane) && root !== null) {
11529
- var queueLanes = queue.lanes; // If any entangled lanes are no longer pending on the root, then they
11530
- // must have finished. We can remove them from the shared queue, which
11531
- // represents a superset of the actually pending lanes. In some cases we
11532
- // may entangle more than we need to, but that's OK. In fact it's worse if
11533
- // we *don't* entangle when we should.
11874
+ if (root !== null) {
11875
+ entangleTransitionUpdate(root, queue, lane);
11876
+ }
11877
+ }
11878
+ }
11879
+
11880
+ function isRenderPhaseUpdate(fiber) {
11881
+ var alternate = fiber.alternate;
11882
+ return (
11883
+ fiber === currentlyRenderingFiber$1 ||
11884
+ (alternate !== null && alternate === currentlyRenderingFiber$1)
11885
+ );
11886
+ }
11887
+
11888
+ function enqueueRenderPhaseUpdate(queue, update) {
11889
+ // This is a render phase update. Stash it in a lazily-created map of
11890
+ // queue -> linked list of updates. After this render pass, we'll restart
11891
+ // and apply the stashed updates on top of the work-in-progress hook.
11892
+ didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true;
11893
+ var pending = queue.pending;
11534
11894
 
11535
- queueLanes = intersectLanes(queueLanes, root.pendingLanes); // Entangle the new transition lane with the other transition lanes.
11895
+ if (pending === null) {
11896
+ // This is the first update. Create a circular list.
11897
+ update.next = update;
11898
+ } else {
11899
+ update.next = pending.next;
11900
+ pending.next = update;
11901
+ }
11902
+
11903
+ queue.pending = update;
11904
+ }
11905
+
11906
+ function enqueueUpdate$1(fiber, queue, update, lane) {
11907
+ if (isInterleavedUpdate(fiber)) {
11908
+ var interleaved = queue.interleaved;
11536
11909
 
11537
- var newQueueLanes = mergeLanes(queueLanes, lane);
11538
- queue.lanes = newQueueLanes; // Even if queue.lanes already include lane, we don't know for certain if
11539
- // the lane finished since the last time we entangled it. So we need to
11540
- // entangle it again, just to be sure.
11910
+ if (interleaved === null) {
11911
+ // This is the first update. Create a circular list.
11912
+ update.next = update; // At the end of the current render, this queue's interleaved updates will
11913
+ // be transferred to the pending queue.
11541
11914
 
11542
- markRootEntangled(root, newQueueLanes);
11915
+ pushInterleavedQueue(queue);
11916
+ } else {
11917
+ update.next = interleaved.next;
11918
+ interleaved.next = update;
11543
11919
  }
11920
+
11921
+ queue.interleaved = update;
11922
+ } else {
11923
+ var pending = queue.pending;
11924
+
11925
+ if (pending === null) {
11926
+ // This is the first update. Create a circular list.
11927
+ update.next = update;
11928
+ } else {
11929
+ update.next = pending.next;
11930
+ pending.next = update;
11931
+ }
11932
+
11933
+ queue.pending = update;
11934
+ }
11935
+ }
11936
+
11937
+ function entangleTransitionUpdate(root, queue, lane) {
11938
+ if (isTransitionLane(lane)) {
11939
+ var queueLanes = queue.lanes; // If any entangled lanes are no longer pending on the root, then they
11940
+ // must have finished. We can remove them from the shared queue, which
11941
+ // represents a superset of the actually pending lanes. In some cases we
11942
+ // may entangle more than we need to, but that's OK. In fact it's worse if
11943
+ // we *don't* entangle when we should.
11944
+
11945
+ queueLanes = intersectLanes(queueLanes, root.pendingLanes); // Entangle the new transition lane with the other transition lanes.
11946
+
11947
+ var newQueueLanes = mergeLanes(queueLanes, lane);
11948
+ queue.lanes = newQueueLanes; // Even if queue.lanes already include lane, we don't know for certain if
11949
+ // the lane finished since the last time we entangled it. So we need to
11950
+ // entangle it again, just to be sure.
11951
+
11952
+ markRootEntangled(root, newQueueLanes);
11544
11953
  }
11545
11954
  }
11546
11955
 
@@ -11550,6 +11959,7 @@ var ContextOnlyDispatcher = {
11550
11959
  useContext: throwInvalidHookError,
11551
11960
  useEffect: throwInvalidHookError,
11552
11961
  useImperativeHandle: throwInvalidHookError,
11962
+ useInsertionEffect: throwInvalidHookError,
11553
11963
  useLayoutEffect: throwInvalidHookError,
11554
11964
  useMemo: throwInvalidHookError,
11555
11965
  useReducer: throwInvalidHookError,
@@ -11559,6 +11969,7 @@ var ContextOnlyDispatcher = {
11559
11969
  useDeferredValue: throwInvalidHookError,
11560
11970
  useTransition: throwInvalidHookError,
11561
11971
  useMutableSource: throwInvalidHookError,
11972
+ useSyncExternalStore: throwInvalidHookError,
11562
11973
  useOpaqueIdentifier: throwInvalidHookError,
11563
11974
  unstable_isNewReconciler: enableNewReconciler
11564
11975
  };
@@ -11617,6 +12028,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
11617
12028
  checkDepsAreArrayDev(deps);
11618
12029
  return mountImperativeHandle(ref, create, deps);
11619
12030
  },
12031
+ useInsertionEffect: function(create, deps) {
12032
+ currentHookNameInDev = "useInsertionEffect";
12033
+ mountHookTypesDev();
12034
+ checkDepsAreArrayDev(deps);
12035
+ return mountInsertionEffect(create, deps);
12036
+ },
11620
12037
  useLayoutEffect: function(create, deps) {
11621
12038
  currentHookNameInDev = "useLayoutEffect";
11622
12039
  mountHookTypesDev();
@@ -11685,6 +12102,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
11685
12102
  mountHookTypesDev();
11686
12103
  return mountMutableSource(source, getSnapshot, subscribe);
11687
12104
  },
12105
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
12106
+ currentHookNameInDev = "useSyncExternalStore";
12107
+ mountHookTypesDev();
12108
+ return mountSyncExternalStore(subscribe, getSnapshot);
12109
+ },
11688
12110
  useOpaqueIdentifier: function() {
11689
12111
  currentHookNameInDev = "useOpaqueIdentifier";
11690
12112
  mountHookTypesDev();
@@ -11717,6 +12139,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
11717
12139
  updateHookTypesDev();
11718
12140
  return mountImperativeHandle(ref, create, deps);
11719
12141
  },
12142
+ useInsertionEffect: function(create, deps) {
12143
+ currentHookNameInDev = "useInsertionEffect";
12144
+ updateHookTypesDev();
12145
+ return mountInsertionEffect(create, deps);
12146
+ },
11720
12147
  useLayoutEffect: function(create, deps) {
11721
12148
  currentHookNameInDev = "useLayoutEffect";
11722
12149
  updateHookTypesDev();
@@ -11783,6 +12210,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
11783
12210
  updateHookTypesDev();
11784
12211
  return mountMutableSource(source, getSnapshot, subscribe);
11785
12212
  },
12213
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
12214
+ currentHookNameInDev = "useSyncExternalStore";
12215
+ updateHookTypesDev();
12216
+ return mountSyncExternalStore(subscribe, getSnapshot);
12217
+ },
11786
12218
  useOpaqueIdentifier: function() {
11787
12219
  currentHookNameInDev = "useOpaqueIdentifier";
11788
12220
  updateHookTypesDev();
@@ -11815,6 +12247,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
11815
12247
  updateHookTypesDev();
11816
12248
  return updateImperativeHandle(ref, create, deps);
11817
12249
  },
12250
+ useInsertionEffect: function(create, deps) {
12251
+ currentHookNameInDev = "useInsertionEffect";
12252
+ updateHookTypesDev();
12253
+ return updateInsertionEffect(create, deps);
12254
+ },
11818
12255
  useLayoutEffect: function(create, deps) {
11819
12256
  currentHookNameInDev = "useLayoutEffect";
11820
12257
  updateHookTypesDev();
@@ -11881,6 +12318,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
11881
12318
  updateHookTypesDev();
11882
12319
  return updateMutableSource(source, getSnapshot, subscribe);
11883
12320
  },
12321
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
12322
+ currentHookNameInDev = "useSyncExternalStore";
12323
+ updateHookTypesDev();
12324
+ return updateSyncExternalStore(subscribe, getSnapshot);
12325
+ },
11884
12326
  useOpaqueIdentifier: function() {
11885
12327
  currentHookNameInDev = "useOpaqueIdentifier";
11886
12328
  updateHookTypesDev();
@@ -11913,6 +12355,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
11913
12355
  updateHookTypesDev();
11914
12356
  return updateImperativeHandle(ref, create, deps);
11915
12357
  },
12358
+ useInsertionEffect: function(create, deps) {
12359
+ currentHookNameInDev = "useInsertionEffect";
12360
+ updateHookTypesDev();
12361
+ return updateInsertionEffect(create, deps);
12362
+ },
11916
12363
  useLayoutEffect: function(create, deps) {
11917
12364
  currentHookNameInDev = "useLayoutEffect";
11918
12365
  updateHookTypesDev();
@@ -11979,6 +12426,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
11979
12426
  updateHookTypesDev();
11980
12427
  return updateMutableSource(source, getSnapshot, subscribe);
11981
12428
  },
12429
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
12430
+ currentHookNameInDev = "useSyncExternalStore";
12431
+ updateHookTypesDev();
12432
+ return updateSyncExternalStore(subscribe, getSnapshot);
12433
+ },
11982
12434
  useOpaqueIdentifier: function() {
11983
12435
  currentHookNameInDev = "useOpaqueIdentifier";
11984
12436
  updateHookTypesDev();
@@ -12016,6 +12468,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
12016
12468
  mountHookTypesDev();
12017
12469
  return mountImperativeHandle(ref, create, deps);
12018
12470
  },
12471
+ useInsertionEffect: function(create, deps) {
12472
+ currentHookNameInDev = "useInsertionEffect";
12473
+ warnInvalidHookAccess();
12474
+ mountHookTypesDev();
12475
+ return mountInsertionEffect(create, deps);
12476
+ },
12019
12477
  useLayoutEffect: function(create, deps) {
12020
12478
  currentHookNameInDev = "useLayoutEffect";
12021
12479
  warnInvalidHookAccess();
@@ -12091,6 +12549,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
12091
12549
  mountHookTypesDev();
12092
12550
  return mountMutableSource(source, getSnapshot, subscribe);
12093
12551
  },
12552
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
12553
+ currentHookNameInDev = "useSyncExternalStore";
12554
+ warnInvalidHookAccess();
12555
+ mountHookTypesDev();
12556
+ return mountSyncExternalStore(subscribe, getSnapshot);
12557
+ },
12094
12558
  useOpaqueIdentifier: function() {
12095
12559
  currentHookNameInDev = "useOpaqueIdentifier";
12096
12560
  warnInvalidHookAccess();
@@ -12129,6 +12593,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
12129
12593
  updateHookTypesDev();
12130
12594
  return updateImperativeHandle(ref, create, deps);
12131
12595
  },
12596
+ useInsertionEffect: function(create, deps) {
12597
+ currentHookNameInDev = "useInsertionEffect";
12598
+ warnInvalidHookAccess();
12599
+ updateHookTypesDev();
12600
+ return updateInsertionEffect(create, deps);
12601
+ },
12132
12602
  useLayoutEffect: function(create, deps) {
12133
12603
  currentHookNameInDev = "useLayoutEffect";
12134
12604
  warnInvalidHookAccess();
@@ -12204,6 +12674,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
12204
12674
  updateHookTypesDev();
12205
12675
  return updateMutableSource(source, getSnapshot, subscribe);
12206
12676
  },
12677
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
12678
+ currentHookNameInDev = "useSyncExternalStore";
12679
+ warnInvalidHookAccess();
12680
+ updateHookTypesDev();
12681
+ return updateSyncExternalStore(subscribe, getSnapshot);
12682
+ },
12207
12683
  useOpaqueIdentifier: function() {
12208
12684
  currentHookNameInDev = "useOpaqueIdentifier";
12209
12685
  warnInvalidHookAccess();
@@ -12242,6 +12718,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
12242
12718
  updateHookTypesDev();
12243
12719
  return updateImperativeHandle(ref, create, deps);
12244
12720
  },
12721
+ useInsertionEffect: function(create, deps) {
12722
+ currentHookNameInDev = "useInsertionEffect";
12723
+ warnInvalidHookAccess();
12724
+ updateHookTypesDev();
12725
+ return updateInsertionEffect(create, deps);
12726
+ },
12245
12727
  useLayoutEffect: function(create, deps) {
12246
12728
  currentHookNameInDev = "useLayoutEffect";
12247
12729
  warnInvalidHookAccess();
@@ -12317,6 +12799,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
12317
12799
  updateHookTypesDev();
12318
12800
  return updateMutableSource(source, getSnapshot, subscribe);
12319
12801
  },
12802
+ useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
12803
+ currentHookNameInDev = "useSyncExternalStore";
12804
+ warnInvalidHookAccess();
12805
+ updateHookTypesDev();
12806
+ return updateSyncExternalStore(subscribe, getSnapshot);
12807
+ },
12320
12808
  useOpaqueIdentifier: function() {
12321
12809
  currentHookNameInDev = "useOpaqueIdentifier";
12322
12810
  warnInvalidHookAccess();
@@ -12503,12 +12991,10 @@ function createCapturedValue(value, source) {
12503
12991
  }
12504
12992
 
12505
12993
  if (
12506
- !(
12507
- typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog ===
12508
- "function"
12509
- )
12994
+ typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog !==
12995
+ "function"
12510
12996
  ) {
12511
- throw Error(
12997
+ throw new Error(
12512
12998
  "Expected ReactFiberErrorDialog.showErrorDialog to be a function."
12513
12999
  );
12514
13000
  }
@@ -12694,129 +13180,144 @@ function createClassErrorUpdate(fiber, errorInfo, lane) {
12694
13180
  return update;
12695
13181
  }
12696
13182
 
12697
- function attachPingListener(root, wakeable, lanes) {
12698
- // Attach a listener to the promise to "ping" the root and retry. But only if
12699
- // one does not already exist for the lanes we're currently rendering (which
12700
- // acts like a "thread ID" here).
12701
- var pingCache = root.pingCache;
12702
- var threadIDs;
12703
-
12704
- if (pingCache === null) {
12705
- pingCache = root.pingCache = new PossiblyWeakMap$1();
12706
- threadIDs = new Set();
12707
- pingCache.set(wakeable, threadIDs);
12708
- } else {
12709
- threadIDs = pingCache.get(wakeable);
12710
-
12711
- if (threadIDs === undefined) {
13183
+ function attachWakeableListeners(suspenseBoundary, root, wakeable, lanes) {
13184
+ // Attach a ping listener
13185
+ //
13186
+ // The data might resolve before we have a chance to commit the fallback. Or,
13187
+ // in the case of a refresh, we'll never commit a fallback. So we need to
13188
+ // attach a listener now. When it resolves ("pings"), we can decide whether to
13189
+ // try rendering the tree again.
13190
+ //
13191
+ // Only attach a listener if one does not already exist for the lanes
13192
+ // we're currently rendering (which acts like a "thread ID" here).
13193
+ //
13194
+ // We only need to do this in concurrent mode. Legacy Suspense always
13195
+ // commits fallbacks synchronously, so there are no pings.
13196
+ if (suspenseBoundary.mode & ConcurrentMode) {
13197
+ var pingCache = root.pingCache;
13198
+ var threadIDs;
13199
+
13200
+ if (pingCache === null) {
13201
+ pingCache = root.pingCache = new PossiblyWeakMap$1();
12712
13202
  threadIDs = new Set();
12713
13203
  pingCache.set(wakeable, threadIDs);
13204
+ } else {
13205
+ threadIDs = pingCache.get(wakeable);
13206
+
13207
+ if (threadIDs === undefined) {
13208
+ threadIDs = new Set();
13209
+ pingCache.set(wakeable, threadIDs);
13210
+ }
12714
13211
  }
12715
- }
12716
13212
 
12717
- if (!threadIDs.has(lanes)) {
12718
- // Memoize using the thread ID to prevent redundant listeners.
12719
- threadIDs.add(lanes);
12720
- var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes);
13213
+ if (!threadIDs.has(lanes)) {
13214
+ // Memoize using the thread ID to prevent redundant listeners.
13215
+ threadIDs.add(lanes);
13216
+ var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes);
12721
13217
 
12722
- {
12723
- if (isDevToolsPresent) {
12724
- // If we have pending work still, restore the original updaters
12725
- restorePendingUpdaters(root, lanes);
13218
+ {
13219
+ if (isDevToolsPresent) {
13220
+ // If we have pending work still, restore the original updaters
13221
+ restorePendingUpdaters(root, lanes);
13222
+ }
12726
13223
  }
13224
+
13225
+ wakeable.then(ping, ping);
12727
13226
  }
13227
+ } // Retry listener
13228
+ //
13229
+ // If the fallback does commit, we need to attach a different type of
13230
+ // listener. This one schedules an update on the Suspense boundary to turn
13231
+ // the fallback state off.
13232
+ //
13233
+ // Stash the wakeable on the boundary fiber so we can access it in the
13234
+ // commit phase.
13235
+ //
13236
+ // When the wakeable resolves, we'll attempt to render the boundary
13237
+ // again ("retry").
12728
13238
 
12729
- wakeable.then(ping, ping);
13239
+ var wakeables = suspenseBoundary.updateQueue;
13240
+
13241
+ if (wakeables === null) {
13242
+ var updateQueue = new Set();
13243
+ updateQueue.add(wakeable);
13244
+ suspenseBoundary.updateQueue = updateQueue;
13245
+ } else {
13246
+ wakeables.add(wakeable);
12730
13247
  }
12731
13248
  }
12732
13249
 
12733
- function throwException(
12734
- root,
12735
- returnFiber,
12736
- sourceFiber,
12737
- value,
12738
- rootRenderLanes
12739
- ) {
12740
- // The source fiber did not complete.
12741
- sourceFiber.flags |= Incomplete;
13250
+ function resetSuspendedComponent(sourceFiber, rootRenderLanes) {
13251
+ // A legacy mode Suspense quirk, only relevant to hook components.
12742
13252
 
12743
- {
12744
- if (isDevToolsPresent) {
12745
- // If we have pending work still, restore the original updaters
12746
- restorePendingUpdaters(root, rootRenderLanes);
12747
- }
12748
- }
13253
+ var tag = sourceFiber.tag;
12749
13254
 
12750
13255
  if (
12751
- value !== null &&
12752
- typeof value === "object" &&
12753
- typeof value.then === "function"
13256
+ (sourceFiber.mode & ConcurrentMode) === NoMode &&
13257
+ (tag === FunctionComponent ||
13258
+ tag === ForwardRef ||
13259
+ tag === SimpleMemoComponent)
12754
13260
  ) {
12755
- var wakeable = value;
12756
- // A legacy mode Suspense quirk, only relevant to hook components.
13261
+ var currentSource = sourceFiber.alternate;
12757
13262
 
12758
- var tag = sourceFiber.tag;
12759
-
12760
- if (
12761
- (sourceFiber.mode & ConcurrentMode) === NoMode &&
12762
- (tag === FunctionComponent ||
12763
- tag === ForwardRef ||
12764
- tag === SimpleMemoComponent)
12765
- ) {
12766
- var currentSource = sourceFiber.alternate;
12767
-
12768
- if (currentSource) {
12769
- sourceFiber.updateQueue = currentSource.updateQueue;
12770
- sourceFiber.memoizedState = currentSource.memoizedState;
12771
- sourceFiber.lanes = currentSource.lanes;
12772
- } else {
12773
- sourceFiber.updateQueue = null;
12774
- sourceFiber.memoizedState = null;
12775
- }
13263
+ if (currentSource) {
13264
+ sourceFiber.updateQueue = currentSource.updateQueue;
13265
+ sourceFiber.memoizedState = currentSource.memoizedState;
13266
+ sourceFiber.lanes = currentSource.lanes;
13267
+ } else {
13268
+ sourceFiber.updateQueue = null;
13269
+ sourceFiber.memoizedState = null;
12776
13270
  }
13271
+ }
13272
+ }
12777
13273
 
12778
- var hasInvisibleParentBoundary = hasSuspenseContext(
12779
- suspenseStackCursor.current,
12780
- InvisibleParentSuspenseContext
12781
- ); // Schedule the nearest Suspense to re-render the timed out view.
12782
-
12783
- var _workInProgress = returnFiber;
13274
+ function markNearestSuspenseBoundaryShouldCapture(
13275
+ returnFiber,
13276
+ sourceFiber,
13277
+ root,
13278
+ rootRenderLanes
13279
+ ) {
13280
+ var hasInvisibleParentBoundary = hasSuspenseContext(
13281
+ suspenseStackCursor.current,
13282
+ InvisibleParentSuspenseContext
13283
+ );
13284
+ var node = returnFiber;
12784
13285
 
12785
- do {
12786
- if (
12787
- _workInProgress.tag === SuspenseComponent &&
12788
- shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)
12789
- ) {
12790
- // Found the nearest boundary.
12791
- // Stash the promise on the boundary fiber. If the boundary times out, we'll
12792
- // attach another listener to flip the boundary back to its normal state.
12793
- var wakeables = _workInProgress.updateQueue;
12794
-
12795
- if (wakeables === null) {
12796
- var updateQueue = new Set();
12797
- updateQueue.add(wakeable);
12798
- _workInProgress.updateQueue = updateQueue;
12799
- } else {
12800
- wakeables.add(wakeable);
12801
- } // If the boundary is in legacy mode, we should *not*
12802
- // suspend the commit. Pretend as if the suspended component rendered
12803
- // null and keep rendering. In the commit phase, we'll schedule a
12804
- // subsequent synchronous update to re-render the Suspense.
12805
- //
12806
- // Note: It doesn't matter whether the component that suspended was
12807
- // inside a concurrent mode tree. If the Suspense is outside of it, we
12808
- // should *not* suspend the commit.
12809
- //
12810
- // If the suspense boundary suspended itself suspended, we don't have to
12811
- // do this trick because nothing was partially started. We can just
12812
- // directly do a second pass over the fallback in this render and
12813
- // pretend we meant to render that directly.
13286
+ do {
13287
+ if (
13288
+ node.tag === SuspenseComponent &&
13289
+ shouldCaptureSuspense(node, hasInvisibleParentBoundary)
13290
+ ) {
13291
+ // Found the nearest boundary.
13292
+ var suspenseBoundary = node; // This marks a Suspense boundary so that when we're unwinding the stack,
13293
+ // it captures the suspended "exception" and does a second (fallback) pass.
12814
13294
 
12815
- if (
12816
- (_workInProgress.mode & ConcurrentMode) === NoMode &&
12817
- _workInProgress !== returnFiber
12818
- ) {
12819
- _workInProgress.flags |= DidCapture;
13295
+ if ((suspenseBoundary.mode & ConcurrentMode) === NoMode) {
13296
+ // Legacy Mode Suspense
13297
+ //
13298
+ // If the boundary is in legacy mode, we should *not*
13299
+ // suspend the commit. Pretend as if the suspended component rendered
13300
+ // null and keep rendering. When the Suspense boundary completes,
13301
+ // we'll do a second pass to render the fallback.
13302
+ if (suspenseBoundary === returnFiber) {
13303
+ // Special case where we suspended while reconciling the children of
13304
+ // a Suspense boundary's inner Offscreen wrapper fiber. This happens
13305
+ // when a React.lazy component is a direct child of a
13306
+ // Suspense boundary.
13307
+ //
13308
+ // Suspense boundaries are implemented as multiple fibers, but they
13309
+ // are a single conceptual unit. The legacy mode behavior where we
13310
+ // pretend the suspended fiber committed as `null` won't work,
13311
+ // because in this case the "suspended" fiber is the inner
13312
+ // Offscreen wrapper.
13313
+ //
13314
+ // Because the contents of the boundary haven't started rendering
13315
+ // yet (i.e. nothing in the tree has partially rendered) we can
13316
+ // switch to the regular, concurrent mode behavior: mark the
13317
+ // boundary with ShouldCapture and enter the unwind phase.
13318
+ suspenseBoundary.flags |= ShouldCapture;
13319
+ } else {
13320
+ suspenseBoundary.flags |= DidCapture;
12820
13321
  sourceFiber.flags |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete.
12821
13322
  // But we shouldn't call any lifecycle methods or callbacks. Remove
12822
13323
  // all lifecycle effect tags.
@@ -12827,10 +13328,10 @@ function throwException(
12827
13328
  // Another legacy Suspense quirk. In persistent mode, if this is the
12828
13329
  // initial mount, override the props of the host container to hide
12829
13330
  // its contents.
12830
- var currentSuspenseBoundary = _workInProgress.alternate;
13331
+ var currentSuspenseBoundary = suspenseBoundary.alternate;
12831
13332
 
12832
13333
  if (currentSuspenseBoundary === null) {
12833
- var offscreenFiber = _workInProgress.child;
13334
+ var offscreenFiber = suspenseBoundary.child;
12834
13335
  var offscreenContainer = offscreenFiber.child;
12835
13336
 
12836
13337
  if (offscreenContainer !== null) {
@@ -12846,9 +13347,9 @@ function throwException(
12846
13347
  }
12847
13348
 
12848
13349
  if (sourceFiber.tag === ClassComponent) {
12849
- var _currentSourceFiber = sourceFiber.alternate;
13350
+ var currentSourceFiber = sourceFiber.alternate;
12850
13351
 
12851
- if (_currentSourceFiber === null) {
13352
+ if (currentSourceFiber === null) {
12852
13353
  // This is a new mount. Change the tag so it's not mistaken for a
12853
13354
  // completed class component. For example, we should not call
12854
13355
  // componentWillUnmount if it is deleted.
@@ -12864,70 +13365,118 @@ function throwException(
12864
13365
  } // The source fiber did not complete. Mark it with Sync priority to
12865
13366
  // indicate that it still has pending work.
12866
13367
 
12867
- sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane); // Exit without suspending.
13368
+ sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane);
13369
+ }
12868
13370
 
12869
- return;
12870
- } // Confirmed that the boundary is in a concurrent mode tree. Continue
12871
- // with the normal suspend path.
12872
- //
12873
- // After this we'll use a set of heuristics to determine whether this
12874
- // render pass will run to completion or restart or "suspend" the commit.
12875
- // The actual logic for this is spread out in different places.
12876
- //
12877
- // This first principle is that if we're going to suspend when we complete
12878
- // a root, then we should also restart if we get an update or ping that
12879
- // might unsuspend it, and vice versa. The only reason to suspend is
12880
- // because you think you might want to restart before committing. However,
12881
- // it doesn't make sense to restart only while in the period we're suspended.
12882
- //
12883
- // Restarting too aggressively is also not good because it starves out any
12884
- // intermediate loading state. So we use heuristics to determine when.
12885
- // Suspense Heuristics
12886
- //
12887
- // If nothing threw a Promise or all the same fallbacks are already showing,
12888
- // then don't suspend/restart.
12889
- //
12890
- // If this is an initial render of a new tree of Suspense boundaries and
12891
- // those trigger a fallback, then don't suspend/restart. We want to ensure
12892
- // that we can show the initial loading state as quickly as possible.
12893
- //
12894
- // If we hit a "Delayed" case, such as when we'd switch from content back into
12895
- // a fallback, then we should always suspend/restart. Transitions apply
12896
- // to this case. If none is defined, JND is used instead.
12897
- //
12898
- // If we're already showing a fallback and it gets "retried", allowing us to show
12899
- // another level, but there's still an inner boundary that would show a fallback,
12900
- // then we suspend/restart for 500ms since the last time we showed a fallback
12901
- // anywhere in the tree. This effectively throttles progressive loading into a
12902
- // consistent train of commits. This also gives us an opportunity to restart to
12903
- // get to the completed state slightly earlier.
12904
- //
12905
- // If there's ambiguity due to batching it's resolved in preference of:
12906
- // 1) "delayed", 2) "initial render", 3) "retry".
12907
- //
12908
- // We want to ensure that a "busy" state doesn't get force committed. We want to
12909
- // ensure that new initial loading states can commit as soon as possible.
13371
+ return suspenseBoundary;
13372
+ } // Confirmed that the boundary is in a concurrent mode tree. Continue
13373
+ // with the normal suspend path.
13374
+ //
13375
+ // After this we'll use a set of heuristics to determine whether this
13376
+ // render pass will run to completion or restart or "suspend" the commit.
13377
+ // The actual logic for this is spread out in different places.
13378
+ //
13379
+ // This first principle is that if we're going to suspend when we complete
13380
+ // a root, then we should also restart if we get an update or ping that
13381
+ // might unsuspend it, and vice versa. The only reason to suspend is
13382
+ // because you think you might want to restart before committing. However,
13383
+ // it doesn't make sense to restart only while in the period we're suspended.
13384
+ //
13385
+ // Restarting too aggressively is also not good because it starves out any
13386
+ // intermediate loading state. So we use heuristics to determine when.
13387
+ // Suspense Heuristics
13388
+ //
13389
+ // If nothing threw a Promise or all the same fallbacks are already showing,
13390
+ // then don't suspend/restart.
13391
+ //
13392
+ // If this is an initial render of a new tree of Suspense boundaries and
13393
+ // those trigger a fallback, then don't suspend/restart. We want to ensure
13394
+ // that we can show the initial loading state as quickly as possible.
13395
+ //
13396
+ // If we hit a "Delayed" case, such as when we'd switch from content back into
13397
+ // a fallback, then we should always suspend/restart. Transitions apply
13398
+ // to this case. If none is defined, JND is used instead.
13399
+ //
13400
+ // If we're already showing a fallback and it gets "retried", allowing us to show
13401
+ // another level, but there's still an inner boundary that would show a fallback,
13402
+ // then we suspend/restart for 500ms since the last time we showed a fallback
13403
+ // anywhere in the tree. This effectively throttles progressive loading into a
13404
+ // consistent train of commits. This also gives us an opportunity to restart to
13405
+ // get to the completed state slightly earlier.
13406
+ //
13407
+ // If there's ambiguity due to batching it's resolved in preference of:
13408
+ // 1) "delayed", 2) "initial render", 3) "retry".
13409
+ //
13410
+ // We want to ensure that a "busy" state doesn't get force committed. We want to
13411
+ // ensure that new initial loading states can commit as soon as possible.
12910
13412
 
12911
- attachPingListener(root, wakeable, rootRenderLanes);
12912
- _workInProgress.flags |= ShouldCapture; // TODO: I think we can remove this, since we now use `DidCapture` in
12913
- // the begin phase to prevent an early bailout.
13413
+ suspenseBoundary.flags |= ShouldCapture; // TODO: I think we can remove this, since we now use `DidCapture` in
13414
+ // the begin phase to prevent an early bailout.
12914
13415
 
12915
- _workInProgress.lanes = rootRenderLanes;
12916
- return;
12917
- } // This boundary already captured during this render. Continue to the next
12918
- // boundary.
13416
+ suspenseBoundary.lanes = rootRenderLanes;
13417
+ return suspenseBoundary;
13418
+ } // This boundary already captured during this render. Continue to the next
13419
+ // boundary.
12919
13420
 
12920
- _workInProgress = _workInProgress.return;
12921
- } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode.
12922
- // TODO: Use invariant so the message is stripped in prod?
13421
+ node = node.return;
13422
+ } while (node !== null); // Could not find a Suspense boundary capable of capturing.
12923
13423
 
12924
- value = new Error(
12925
- (getComponentNameFromFiber(sourceFiber) || "A React component") +
12926
- " suspended while rendering, but no fallback UI was specified.\n" +
12927
- "\n" +
12928
- "Add a <Suspense fallback=...> component higher in the tree to " +
12929
- "provide a loading indicator or placeholder to display."
13424
+ return null;
13425
+ }
13426
+
13427
+ function throwException(
13428
+ root,
13429
+ returnFiber,
13430
+ sourceFiber,
13431
+ value,
13432
+ rootRenderLanes
13433
+ ) {
13434
+ // The source fiber did not complete.
13435
+ sourceFiber.flags |= Incomplete;
13436
+
13437
+ {
13438
+ if (isDevToolsPresent) {
13439
+ // If we have pending work still, restore the original updaters
13440
+ restorePendingUpdaters(root, rootRenderLanes);
13441
+ }
13442
+ }
13443
+
13444
+ if (
13445
+ value !== null &&
13446
+ typeof value === "object" &&
13447
+ typeof value.then === "function"
13448
+ ) {
13449
+ // This is a wakeable. The component suspended.
13450
+ var wakeable = value;
13451
+ resetSuspendedComponent(sourceFiber);
13452
+
13453
+ var suspenseBoundary = markNearestSuspenseBoundaryShouldCapture(
13454
+ returnFiber,
13455
+ sourceFiber,
13456
+ root,
13457
+ rootRenderLanes
12930
13458
  );
13459
+
13460
+ if (suspenseBoundary !== null) {
13461
+ attachWakeableListeners(
13462
+ suspenseBoundary,
13463
+ root,
13464
+ wakeable,
13465
+ rootRenderLanes
13466
+ );
13467
+ return;
13468
+ } else {
13469
+ // No boundary was found. Fallthrough to error mode.
13470
+ // TODO: We should never call getComponentNameFromFiber in production.
13471
+ // Log a warning or something to prevent us from accidentally bundling it.
13472
+ value = new Error(
13473
+ (getComponentNameFromFiber(sourceFiber) || "A React component") +
13474
+ " suspended while rendering, but no fallback UI was specified.\n" +
13475
+ "\n" +
13476
+ "Add a <Suspense fallback=...> component higher in the tree to " +
13477
+ "provide a loading indicator or placeholder to display."
13478
+ );
13479
+ }
12931
13480
  } // We didn't find a boundary that could handle this type of exception. Start
12932
13481
  // over and traverse parent path again, this time treating the exception
12933
13482
  // as an error.
@@ -12943,10 +13492,8 @@ function throwException(
12943
13492
  workInProgress.flags |= ShouldCapture;
12944
13493
  var lane = pickArbitraryLane(rootRenderLanes);
12945
13494
  workInProgress.lanes = mergeLanes(workInProgress.lanes, lane);
12946
-
12947
- var _update = createRootErrorUpdate(workInProgress, _errorInfo, lane);
12948
-
12949
- enqueueCapturedUpdate(workInProgress, _update);
13495
+ var update = createRootErrorUpdate(workInProgress, _errorInfo, lane);
13496
+ enqueueCapturedUpdate(workInProgress, update);
12950
13497
  return;
12951
13498
  }
12952
13499
 
@@ -12969,13 +13516,13 @@ function throwException(
12969
13516
 
12970
13517
  workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state
12971
13518
 
12972
- var _update2 = createClassErrorUpdate(
13519
+ var _update = createClassErrorUpdate(
12973
13520
  workInProgress,
12974
13521
  errorInfo,
12975
13522
  _lane
12976
13523
  );
12977
13524
 
12978
- enqueueCapturedUpdate(workInProgress, _update2);
13525
+ enqueueCapturedUpdate(workInProgress, _update);
12979
13526
  return;
12980
13527
  }
12981
13528
 
@@ -13546,7 +14093,7 @@ function completeWork(current, workInProgress, renderLanes) {
13546
14093
  // If we hydrated, then we'll need to schedule an update for
13547
14094
  // the commit side-effects on the root.
13548
14095
  markUpdate(workInProgress);
13549
- } else if (!fiberRoot.hydrate) {
14096
+ } else if (!fiberRoot.isDehydrated) {
13550
14097
  // Schedule an effect to clear this container at the start of the next commit.
13551
14098
  // This handles the case of React rendering into a container with previous children.
13552
14099
  // It's also safe to do for updates too, because current.child would only be null
@@ -13579,9 +14126,10 @@ function completeWork(current, workInProgress, renderLanes) {
13579
14126
  }
13580
14127
  } else {
13581
14128
  if (!newProps) {
13582
- if (!(workInProgress.stateNode !== null)) {
13583
- throw Error(
13584
- "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
14129
+ if (workInProgress.stateNode === null) {
14130
+ throw new Error(
14131
+ "We must have new props for new mounts. This error is likely " +
14132
+ "caused by a bug in React. Please file an issue."
13585
14133
  );
13586
14134
  } // This can happen when we abort work.
13587
14135
 
@@ -13636,9 +14184,10 @@ function completeWork(current, workInProgress, renderLanes) {
13636
14184
  updateHostText(current, workInProgress, oldText, newText);
13637
14185
  } else {
13638
14186
  if (typeof newText !== "string") {
13639
- if (!(workInProgress.stateNode !== null)) {
13640
- throw Error(
13641
- "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."
14187
+ if (workInProgress.stateNode === null) {
14188
+ throw new Error(
14189
+ "We must have new props for new mounts. This error is likely " +
14190
+ "caused by a bug in React. Please file an issue."
13642
14191
  );
13643
14192
  } // This can happen when we abort work.
13644
14193
  }
@@ -14042,13 +14591,12 @@ function completeWork(current, workInProgress, renderLanes) {
14042
14591
  }
14043
14592
  }
14044
14593
 
14045
- {
14046
- throw Error(
14047
- "Unknown unit of work tag (" +
14048
- workInProgress.tag +
14049
- "). This error is likely caused by a bug in React. Please file an issue."
14050
- );
14051
- }
14594
+ throw new Error(
14595
+ "Unknown unit of work tag (" +
14596
+ workInProgress.tag +
14597
+ "). This error is likely caused by a bug in " +
14598
+ "React. Please file an issue."
14599
+ );
14052
14600
  }
14053
14601
 
14054
14602
  var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
@@ -14178,7 +14726,7 @@ function updateForwardRef(
14178
14726
  );
14179
14727
 
14180
14728
  if (workInProgress.mode & StrictLegacyMode) {
14181
- disableLogs();
14729
+ setIsStrictModeForDevtools(true);
14182
14730
 
14183
14731
  try {
14184
14732
  nextChildren = renderWithHooks(
@@ -14190,7 +14738,7 @@ function updateForwardRef(
14190
14738
  renderLanes
14191
14739
  );
14192
14740
  } finally {
14193
- reenableLogs();
14741
+ setIsStrictModeForDevtools(false);
14194
14742
  }
14195
14743
  }
14196
14744
 
@@ -14648,7 +15196,7 @@ function updateFunctionComponent(
14648
15196
  );
14649
15197
 
14650
15198
  if (workInProgress.mode & StrictLegacyMode) {
14651
- disableLogs();
15199
+ setIsStrictModeForDevtools(true);
14652
15200
 
14653
15201
  try {
14654
15202
  nextChildren = renderWithHooks(
@@ -14660,7 +15208,7 @@ function updateFunctionComponent(
14660
15208
  renderLanes
14661
15209
  );
14662
15210
  } finally {
14663
- reenableLogs();
15211
+ setIsStrictModeForDevtools(false);
14664
15212
  }
14665
15213
  }
14666
15214
 
@@ -14705,7 +15253,8 @@ function updateClassComponent(
14705
15253
 
14706
15254
  case true: {
14707
15255
  workInProgress.flags |= DidCapture;
14708
- workInProgress.flags |= ShouldCapture;
15256
+ workInProgress.flags |= ShouldCapture; // eslint-disable-next-line react-internal/prod-error-codes
15257
+
14709
15258
  var error$1 = new Error("Simulated error coming from DevTools");
14710
15259
  var lane = pickArbitraryLane(renderLanes);
14711
15260
  workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); // Schedule the error boundary to re-render using updated state
@@ -14858,12 +15407,12 @@ function finishClassComponent(
14858
15407
  nextChildren = instance.render();
14859
15408
 
14860
15409
  if (workInProgress.mode & StrictLegacyMode) {
14861
- disableLogs();
15410
+ setIsStrictModeForDevtools(true);
14862
15411
 
14863
15412
  try {
14864
15413
  instance.render();
14865
15414
  } finally {
14866
- reenableLogs();
15415
+ setIsStrictModeForDevtools(false);
14867
15416
  }
14868
15417
  }
14869
15418
 
@@ -14919,9 +15468,11 @@ function updateHostRoot(current, workInProgress, renderLanes) {
14919
15468
  pushHostRootContext(workInProgress);
14920
15469
  var updateQueue = workInProgress.updateQueue;
14921
15470
 
14922
- if (!(current !== null && updateQueue !== null)) {
14923
- throw Error(
14924
- "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue."
15471
+ if (current === null || updateQueue === null) {
15472
+ throw new Error(
15473
+ "If the root does not have an updateQueue, we should have already " +
15474
+ "bailed out. This error is likely caused by a bug in React. Please " +
15475
+ "file an issue."
14925
15476
  );
14926
15477
  }
14927
15478
 
@@ -14940,7 +15491,7 @@ function updateHostRoot(current, workInProgress, renderLanes) {
14940
15491
  return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
14941
15492
  }
14942
15493
 
14943
- if (root.hydrate && enterHydrationState()) {
15494
+ if (root.isDehydrated && enterHydrationState()) {
14944
15495
  var child = mountChildFibers(
14945
15496
  workInProgress,
14946
15497
  null,
@@ -15116,14 +15667,12 @@ function mountLazyComponent(
15116
15667
  // because the fact that it's a separate type of work is an
15117
15668
  // implementation detail.
15118
15669
 
15119
- {
15120
- throw Error(
15121
- "Element type is invalid. Received a promise that resolves to: " +
15122
- Component +
15123
- ". Lazy element type must resolve to a class or function." +
15124
- hint
15125
- );
15126
- }
15670
+ throw new Error(
15671
+ "Element type is invalid. Received a promise that resolves to: " +
15672
+ Component +
15673
+ ". " +
15674
+ ("Lazy element type must resolve to a class or function." + hint)
15675
+ );
15127
15676
  }
15128
15677
 
15129
15678
  function mountIncompleteClassComponent(
@@ -15327,7 +15876,7 @@ function mountIndeterminateComponent(
15327
15876
 
15328
15877
  {
15329
15878
  if (workInProgress.mode & StrictLegacyMode) {
15330
- disableLogs();
15879
+ setIsStrictModeForDevtools(true);
15331
15880
 
15332
15881
  try {
15333
15882
  value = renderWithHooks(
@@ -15339,7 +15888,7 @@ function mountIndeterminateComponent(
15339
15888
  renderLanes
15340
15889
  );
15341
15890
  } finally {
15342
- reenableLogs();
15891
+ setIsStrictModeForDevtools(false);
15343
15892
  }
15344
15893
  }
15345
15894
  }
@@ -16507,6 +17056,7 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) {
16507
17056
  var returnFiber = oldWorkInProgress.return;
16508
17057
 
16509
17058
  if (returnFiber === null) {
17059
+ // eslint-disable-next-line react-internal/prod-error-codes
16510
17060
  throw new Error("Cannot swap the root fiber.");
16511
17061
  } // Disconnect from the old current.
16512
17062
  // It will get deleted.
@@ -16525,6 +17075,7 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) {
16525
17075
  var prevSibling = returnFiber.child;
16526
17076
 
16527
17077
  if (prevSibling === null) {
17078
+ // eslint-disable-next-line react-internal/prod-error-codes
16528
17079
  throw new Error("Expected parent to have a child.");
16529
17080
  }
16530
17081
 
@@ -16532,6 +17083,7 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) {
16532
17083
  prevSibling = prevSibling.sibling;
16533
17084
 
16534
17085
  if (prevSibling === null) {
17086
+ // eslint-disable-next-line react-internal/prod-error-codes
16535
17087
  throw new Error("Expected to find the previous sibling.");
16536
17088
  }
16537
17089
  }
@@ -17001,13 +17553,12 @@ function beginWork(current, workInProgress, renderLanes) {
17001
17553
  }
17002
17554
  }
17003
17555
 
17004
- {
17005
- throw Error(
17006
- "Unknown unit of work tag (" +
17007
- workInProgress.tag +
17008
- "). This error is likely caused by a bug in React. Please file an issue."
17009
- );
17010
- }
17556
+ throw new Error(
17557
+ "Unknown unit of work tag (" +
17558
+ workInProgress.tag +
17559
+ "). This error is likely caused by a bug in " +
17560
+ "React. Please file an issue."
17561
+ );
17011
17562
  }
17012
17563
 
17013
17564
  function unwindWork(workInProgress, renderLanes) {
@@ -17040,9 +17591,10 @@ function unwindWork(workInProgress, renderLanes) {
17040
17591
  resetWorkInProgressVersions();
17041
17592
  var _flags = workInProgress.flags;
17042
17593
 
17043
- if (!((_flags & DidCapture) === NoFlags)) {
17044
- throw Error(
17045
- "The root failed to unmount after an error. This is likely a bug in React. Please file an issue."
17594
+ if ((_flags & DidCapture) !== NoFlags) {
17595
+ throw new Error(
17596
+ "The root failed to unmount after an error. This is likely a bug in " +
17597
+ "React. Please file an issue."
17046
17598
  );
17047
17599
  }
17048
17600
 
@@ -17212,6 +17764,8 @@ function safelyDetachRef(current, nearestMountedAncestor) {
17212
17764
 
17213
17765
  if (ref !== null) {
17214
17766
  if (typeof ref === "function") {
17767
+ var retVal;
17768
+
17215
17769
  try {
17216
17770
  if (
17217
17771
  enableProfilerTimer &&
@@ -17220,12 +17774,12 @@ function safelyDetachRef(current, nearestMountedAncestor) {
17220
17774
  ) {
17221
17775
  try {
17222
17776
  startLayoutEffectTimer();
17223
- ref(null);
17777
+ retVal = ref(null);
17224
17778
  } finally {
17225
17779
  recordLayoutEffectDuration(current);
17226
17780
  }
17227
17781
  } else {
17228
- ref(null);
17782
+ retVal = ref(null);
17229
17783
  }
17230
17784
  } catch (error) {
17231
17785
  reportUncaughtErrorInDEV(error);
@@ -17392,11 +17946,10 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) {
17392
17946
  break;
17393
17947
 
17394
17948
  default: {
17395
- {
17396
- throw Error(
17397
- "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."
17398
- );
17399
- }
17949
+ throw new Error(
17950
+ "This unit of work tag should not have side-effects. This error is " +
17951
+ "likely caused by a bug in React. Please file an issue."
17952
+ );
17400
17953
  }
17401
17954
  }
17402
17955
 
@@ -17450,6 +18003,16 @@ function commitHookEffectListMount(tag, finishedWork) {
17450
18003
  var destroy = effect.destroy;
17451
18004
 
17452
18005
  if (destroy !== undefined && typeof destroy !== "function") {
18006
+ var hookName = void 0;
18007
+
18008
+ if ((effect.tag & Layout) !== NoFlags) {
18009
+ hookName = "useLayoutEffect";
18010
+ } else if ((effect.tag & Insertion) !== NoFlags) {
18011
+ hookName = "useInsertionEffect";
18012
+ } else {
18013
+ hookName = "useEffect";
18014
+ }
18015
+
17453
18016
  var addendum = void 0;
17454
18017
 
17455
18018
  if (destroy === null) {
@@ -17458,10 +18021,13 @@ function commitHookEffectListMount(tag, finishedWork) {
17458
18021
  "up, return undefined (or nothing).";
17459
18022
  } else if (typeof destroy.then === "function") {
17460
18023
  addendum =
17461
- "\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. " +
18024
+ "\n\nIt looks like you wrote " +
18025
+ hookName +
18026
+ "(async () => ...) or returned a Promise. " +
17462
18027
  "Instead, write the async function inside your effect " +
17463
18028
  "and call it immediately:\n\n" +
17464
- "useEffect(() => {\n" +
18029
+ hookName +
18030
+ "(() => {\n" +
17465
18031
  " async function fetchData() {\n" +
17466
18032
  " // You can await here\n" +
17467
18033
  " const response = await MyAPI.getData(someId);\n" +
@@ -17475,8 +18041,9 @@ function commitHookEffectListMount(tag, finishedWork) {
17475
18041
  }
17476
18042
 
17477
18043
  error(
17478
- "An effect function must not return anything besides a function, " +
18044
+ "%s must not return anything besides a function, " +
17479
18045
  "which is used for clean-up.%s",
18046
+ hookName,
17480
18047
  addendum
17481
18048
  );
17482
18049
  }
@@ -17849,11 +18416,11 @@ function commitLayoutEffectOnFiber(
17849
18416
  case LegacyHiddenComponent:
17850
18417
  break;
17851
18418
 
17852
- default: {
17853
- throw Error(
17854
- "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."
18419
+ default:
18420
+ throw new Error(
18421
+ "This unit of work tag should not have side-effects. This error is " +
18422
+ "likely caused by a bug in React. Please file an issue."
17855
18423
  );
17856
- }
17857
18424
  }
17858
18425
  }
17859
18426
 
@@ -17883,15 +18450,17 @@ function commitAttachRef(finishedWork) {
17883
18450
  } // Moved outside to ensure DCE works with this flag
17884
18451
 
17885
18452
  if (typeof ref === "function") {
18453
+ var retVal;
18454
+
17886
18455
  if (finishedWork.mode & ProfileMode) {
17887
18456
  try {
17888
18457
  startLayoutEffectTimer();
17889
- ref(instanceToUse);
18458
+ retVal = ref(instanceToUse);
17890
18459
  } finally {
17891
18460
  recordLayoutEffectDuration(finishedWork);
17892
18461
  }
17893
18462
  } else {
17894
- ref(instanceToUse);
18463
+ retVal = ref(instanceToUse);
17895
18464
  }
17896
18465
  } else {
17897
18466
  {
@@ -17955,7 +18524,10 @@ function commitUnmount(finishedRoot, current, nearestMountedAncestor) {
17955
18524
  tag = _effect.tag;
17956
18525
 
17957
18526
  if (destroy !== undefined) {
17958
- if ((tag & Layout) !== NoFlags$1) {
18527
+ if (
18528
+ (tag & Insertion) !== NoFlags$1 ||
18529
+ (tag & Layout) !== NoFlags$1
18530
+ ) {
17959
18531
  if (current.mode & ProfileMode) {
17960
18532
  startLayoutEffectTimer();
17961
18533
  safelyCallDestroy(current, nearestMountedAncestor, destroy);
@@ -18160,11 +18732,10 @@ function commitContainer(finishedWork) {
18160
18732
  }
18161
18733
  }
18162
18734
 
18163
- {
18164
- throw Error(
18165
- "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."
18166
- );
18167
- }
18735
+ throw new Error(
18736
+ "This unit of work tag should not have side-effects. This error is " +
18737
+ "likely caused by a bug in React. Please file an issue."
18738
+ );
18168
18739
  }
18169
18740
 
18170
18741
  function commitDeletion(finishedRoot, current, nearestMountedAncestor) {
@@ -18183,7 +18754,12 @@ function commitWork(current, finishedWork) {
18183
18754
  case ForwardRef:
18184
18755
  case MemoComponent:
18185
18756
  case SimpleMemoComponent: {
18186
- // Layout effects are destroyed during the mutation phase so that all
18757
+ commitHookEffectListUnmount(
18758
+ Insertion | HasEffect,
18759
+ finishedWork,
18760
+ finishedWork.return
18761
+ );
18762
+ commitHookEffectListMount(Insertion | HasEffect, finishedWork); // Layout effects are destroyed during the mutation phase so that all
18187
18763
  // destroy functions for all fibers are called before any create functions.
18188
18764
  // This prevents sibling component effects from interfering with each other,
18189
18765
  // e.g. a destroy function in one component should never override a ref set
@@ -18193,6 +18769,7 @@ function commitWork(current, finishedWork) {
18193
18769
  // layout hooks. (However, since we null out the `destroy` function
18194
18770
  // right before calling it, the behavior is already correct, so this
18195
18771
  // would mostly be for modeling purposes.)
18772
+
18196
18773
  if (finishedWork.mode & ProfileMode) {
18197
18774
  try {
18198
18775
  startLayoutEffectTimer();
@@ -19048,13 +19625,13 @@ function requestUpdateLane(fiber) {
19048
19625
  var isTransition = requestCurrentTransition() !== NoTransition;
19049
19626
 
19050
19627
  if (isTransition) {
19051
- // The algorithm for assigning an update to a lane should be stable for all
19052
19628
  // updates at the same priority within the same event. To do this, the
19053
19629
  // inputs to the algorithm must be the same.
19054
19630
  //
19055
19631
  // The trick we use is to cache the first of each of these inputs within an
19056
19632
  // event. Then reset the cached values once we can be sure the event is
19057
19633
  // over. Our heuristic for that is whenever we enter a concurrent work loop.
19634
+
19058
19635
  if (currentEventTransitionLane === NoLane) {
19059
19636
  // All transitions within the same event are assigned the same lane.
19060
19637
  currentEventTransitionLane = claimNextTransitionLane();
@@ -19349,8 +19926,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
19349
19926
  currentEventTime = NoTimestamp;
19350
19927
  currentEventTransitionLane = NoLanes;
19351
19928
 
19352
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
19353
- throw Error("Should not already be working.");
19929
+ if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
19930
+ throw new Error("Should not already be working.");
19354
19931
  } // Flush any pending passive effects before deciding which lanes to work on,
19355
19932
  // in case they schedule additional work.
19356
19933
 
@@ -19384,38 +19961,26 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
19384
19961
  // bug we're still investigating. Once the bug in Scheduler is fixed,
19385
19962
  // we can remove this, since we track expiration ourselves.
19386
19963
 
19387
- var exitStatus =
19388
- shouldTimeSlice(root, lanes) && !didTimeout
19389
- ? renderRootConcurrent(root, lanes)
19390
- : renderRootSync(root, lanes);
19964
+ var shouldTimeSlice =
19965
+ !includesBlockingLane(root, lanes) &&
19966
+ !includesExpiredLane(root, lanes) &&
19967
+ !didTimeout;
19968
+ var exitStatus = shouldTimeSlice
19969
+ ? renderRootConcurrent(root, lanes)
19970
+ : renderRootSync(root, lanes);
19391
19971
 
19392
19972
  if (exitStatus !== RootIncomplete) {
19393
19973
  if (exitStatus === RootErrored) {
19394
- var prevExecutionContext = executionContext;
19395
- executionContext |= RetryAfterError; // If an error occurred during hydration,
19396
- // discard server response and fall back to client side render.
19397
-
19398
- if (root.hydrate) {
19399
- root.hydrate = false;
19400
-
19401
- {
19402
- errorHydratingContainer(root.containerInfo);
19403
- }
19404
-
19405
- clearContainer(root.containerInfo);
19406
- } // If something threw an error, try rendering one more time. We'll render
19407
- // synchronously to block concurrent data mutations, and we'll includes
19408
- // all pending updates are included. If it still fails after the second
19409
- // attempt, we'll give up and commit the resulting tree.
19410
-
19974
+ // If something threw an error, try rendering one more time. We'll
19975
+ // render synchronously to block concurrent data mutations, and we'll
19976
+ // includes all pending updates are included. If it still fails after
19977
+ // the second attempt, we'll give up and commit the resulting tree.
19411
19978
  var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root);
19412
19979
 
19413
19980
  if (errorRetryLanes !== NoLanes) {
19414
19981
  lanes = errorRetryLanes;
19415
- exitStatus = renderRootSync(root, errorRetryLanes);
19982
+ exitStatus = recoverFromConcurrentError(root, errorRetryLanes);
19416
19983
  }
19417
-
19418
- executionContext = prevExecutionContext;
19419
19984
  }
19420
19985
 
19421
19986
  if (exitStatus === RootFatalErrored) {
@@ -19424,10 +19989,43 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
19424
19989
  markRootSuspended$1(root, lanes);
19425
19990
  ensureRootIsScheduled(root, now());
19426
19991
  throw fatalError;
19992
+ } // Check if this render may have yielded to a concurrent event, and if so,
19993
+ // confirm that any newly rendered stores are consistent.
19994
+ // TODO: It's possible that even a concurrent render may never have yielded
19995
+ // to the main thread, if it was fast enough, or if it expired. We could
19996
+ // skip the consistency check in that case, too.
19997
+
19998
+ var renderWasConcurrent = !includesBlockingLane(root, lanes);
19999
+ var finishedWork = root.current.alternate;
20000
+
20001
+ if (
20002
+ renderWasConcurrent &&
20003
+ !isRenderConsistentWithExternalStores(finishedWork)
20004
+ ) {
20005
+ // A store was mutated in an interleaved event. Render again,
20006
+ // synchronously, to block further mutations.
20007
+ exitStatus = renderRootSync(root, lanes); // We need to check again if something threw
20008
+
20009
+ if (exitStatus === RootErrored) {
20010
+ var _errorRetryLanes = getLanesToRetrySynchronouslyOnError(root);
20011
+
20012
+ if (_errorRetryLanes !== NoLanes) {
20013
+ lanes = _errorRetryLanes;
20014
+ exitStatus = recoverFromConcurrentError(root, _errorRetryLanes); // We assume the tree is now consistent because we didn't yield to any
20015
+ // concurrent events.
20016
+ }
20017
+ }
20018
+
20019
+ if (exitStatus === RootFatalErrored) {
20020
+ var _fatalError = workInProgressRootFatalError;
20021
+ prepareFreshStack(root, NoLanes);
20022
+ markRootSuspended$1(root, lanes);
20023
+ ensureRootIsScheduled(root, now());
20024
+ throw _fatalError;
20025
+ }
19427
20026
  } // We now have a consistent tree. The next step is either to commit it,
19428
20027
  // or, if something suspended, wait to commit it after a timeout.
19429
20028
 
19430
- var finishedWork = root.current.alternate;
19431
20029
  root.finishedWork = finishedWork;
19432
20030
  root.finishedLanes = lanes;
19433
20031
  finishConcurrentRender(root, exitStatus, lanes);
@@ -19444,13 +20042,31 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
19444
20042
  return null;
19445
20043
  }
19446
20044
 
20045
+ function recoverFromConcurrentError(root, errorRetryLanes) {
20046
+ var prevExecutionContext = executionContext;
20047
+ executionContext |= RetryAfterError; // If an error occurred during hydration, discard server response and fall
20048
+ // back to client side render.
20049
+
20050
+ if (root.isDehydrated) {
20051
+ root.isDehydrated = false;
20052
+
20053
+ {
20054
+ errorHydratingContainer(root.containerInfo);
20055
+ }
20056
+
20057
+ clearContainer(root.containerInfo);
20058
+ }
20059
+
20060
+ var exitStatus = renderRootSync(root, errorRetryLanes);
20061
+ executionContext = prevExecutionContext;
20062
+ return exitStatus;
20063
+ }
20064
+
19447
20065
  function finishConcurrentRender(root, exitStatus, lanes) {
19448
20066
  switch (exitStatus) {
19449
20067
  case RootIncomplete:
19450
20068
  case RootFatalErrored: {
19451
- {
19452
- throw Error("Root did not complete. This is a bug in React.");
19453
- }
20069
+ throw new Error("Root did not complete. This is a bug in React.");
19454
20070
  }
19455
20071
  // Flow knows about invariant, so it complains if I add a break
19456
20072
  // statement, but eslint doesn't know about invariant, so it complains
@@ -19555,13 +20171,73 @@ function finishConcurrentRender(root, exitStatus, lanes) {
19555
20171
  }
19556
20172
 
19557
20173
  default: {
19558
- {
19559
- throw Error("Unknown root exit status.");
19560
- }
20174
+ throw new Error("Unknown root exit status.");
19561
20175
  }
19562
20176
  }
19563
20177
  }
19564
20178
 
20179
+ function isRenderConsistentWithExternalStores(finishedWork) {
20180
+ // Search the rendered tree for external store reads, and check whether the
20181
+ // stores were mutated in a concurrent event. Intentionally using a iterative
20182
+ // loop instead of recursion so we can exit early.
20183
+ var node = finishedWork;
20184
+
20185
+ while (true) {
20186
+ if (node.flags & StoreConsistency) {
20187
+ var updateQueue = node.updateQueue;
20188
+
20189
+ if (updateQueue !== null) {
20190
+ var checks = updateQueue.stores;
20191
+
20192
+ if (checks !== null) {
20193
+ for (var i = 0; i < checks.length; i++) {
20194
+ var check = checks[i];
20195
+ var getSnapshot = check.getSnapshot;
20196
+ var renderedValue = check.value;
20197
+
20198
+ try {
20199
+ if (!objectIs(getSnapshot(), renderedValue)) {
20200
+ // Found an inconsistent store.
20201
+ return false;
20202
+ }
20203
+ } catch (error) {
20204
+ // If `getSnapshot` throws, return `false`. This will schedule
20205
+ // a re-render, and the error will be rethrown during render.
20206
+ return false;
20207
+ }
20208
+ }
20209
+ }
20210
+ }
20211
+ }
20212
+
20213
+ var child = node.child;
20214
+
20215
+ if (node.subtreeFlags & StoreConsistency && child !== null) {
20216
+ child.return = node;
20217
+ node = child;
20218
+ continue;
20219
+ }
20220
+
20221
+ if (node === finishedWork) {
20222
+ return true;
20223
+ }
20224
+
20225
+ while (node.sibling === null) {
20226
+ if (node.return === null || node.return === finishedWork) {
20227
+ return true;
20228
+ }
20229
+
20230
+ node = node.return;
20231
+ }
20232
+
20233
+ node.sibling.return = node.return;
20234
+ node = node.sibling;
20235
+ } // Flow doesn't know this is unreachable, but eslint does
20236
+ // eslint-disable-next-line no-unreachable
20237
+
20238
+ return true;
20239
+ }
20240
+
19565
20241
  function markRootSuspended$1(root, suspendedLanes) {
19566
20242
  // When suspending, we should always exclude lanes that were pinged or (more
19567
20243
  // rarely, since we try to avoid it) updated during the render phase.
@@ -19578,8 +20254,8 @@ function performSyncWorkOnRoot(root) {
19578
20254
  syncNestedUpdateFlag();
19579
20255
  }
19580
20256
 
19581
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
19582
- throw Error("Should not already be working.");
20257
+ if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
20258
+ throw new Error("Should not already be working.");
19583
20259
  }
19584
20260
 
19585
20261
  flushPassiveEffects();
@@ -19598,8 +20274,8 @@ function performSyncWorkOnRoot(root) {
19598
20274
  executionContext |= RetryAfterError; // If an error occurred during hydration,
19599
20275
  // discard server response and fall back to client side render.
19600
20276
 
19601
- if (root.hydrate) {
19602
- root.hydrate = false;
20277
+ if (root.isDehydrated) {
20278
+ root.isDehydrated = false;
19603
20279
 
19604
20280
  {
19605
20281
  errorHydratingContainer(root.containerInfo);
@@ -19661,7 +20337,7 @@ function batchedUpdates$1(fn, a) {
19661
20337
  // Warning, this opts-out of checking the function body.
19662
20338
 
19663
20339
  // eslint-disable-next-line no-redeclare
19664
- function flushSyncWithoutWarningIfAlreadyRendering(fn) {
20340
+ function flushSync(fn) {
19665
20341
  // In legacy mode, we flush pending passive effects at the beginning of the
19666
20342
  // next event, not at the end of the previous one.
19667
20343
  if (
@@ -19697,22 +20373,6 @@ function flushSyncWithoutWarningIfAlreadyRendering(fn) {
19697
20373
  flushSyncCallbacks();
19698
20374
  }
19699
20375
  }
19700
- } // Overload the definition to the two valid signatures.
19701
- // Warning, this opts-out of checking the function body.
19702
-
19703
- // eslint-disable-next-line no-redeclare
19704
- function flushSync(fn) {
19705
- {
19706
- if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
19707
- error(
19708
- "flushSync was called from inside a lifecycle method. React cannot " +
19709
- "flush when React is already rendering. Consider moving this call to " +
19710
- "a scheduler task or micro task."
19711
- );
19712
- }
19713
- }
19714
-
19715
- return flushSyncWithoutWarningIfAlreadyRendering(fn);
19716
20376
  }
19717
20377
  function pushRenderLanes(fiber, lanes) {
19718
20378
  push(subtreeRenderLanesCursor, subtreeRenderLanes, fiber);
@@ -19801,6 +20461,29 @@ function handleError(root, thrownValue) {
19801
20461
  stopProfilerTimerIfRunningAndRecordDelta(erroredWork, true);
19802
20462
  }
19803
20463
 
20464
+ if (enableSchedulingProfiler) {
20465
+ markComponentRenderStopped();
20466
+
20467
+ if (
20468
+ thrownValue !== null &&
20469
+ typeof thrownValue === "object" &&
20470
+ typeof thrownValue.then === "function"
20471
+ ) {
20472
+ var wakeable = thrownValue;
20473
+ markComponentSuspended(
20474
+ erroredWork,
20475
+ wakeable,
20476
+ workInProgressRootRenderLanes
20477
+ );
20478
+ } else {
20479
+ markComponentErrored(
20480
+ erroredWork,
20481
+ thrownValue,
20482
+ workInProgressRootRenderLanes
20483
+ );
20484
+ }
20485
+ }
20486
+
19804
20487
  throwException(
19805
20488
  root,
19806
20489
  erroredWork.return,
@@ -19864,7 +20547,8 @@ function renderDidSuspend() {
19864
20547
  function renderDidSuspendDelayIfPossible() {
19865
20548
  if (
19866
20549
  workInProgressRootExitStatus === RootIncomplete ||
19867
- workInProgressRootExitStatus === RootSuspended
20550
+ workInProgressRootExitStatus === RootSuspended ||
20551
+ workInProgressRootExitStatus === RootErrored
19868
20552
  ) {
19869
20553
  workInProgressRootExitStatus = RootSuspendedWithDelay;
19870
20554
  } // Check if there are updates that we skipped tree that might have unblocked
@@ -19886,7 +20570,7 @@ function renderDidSuspendDelayIfPossible() {
19886
20570
  }
19887
20571
  }
19888
20572
  function renderDidError() {
19889
- if (workInProgressRootExitStatus !== RootCompleted) {
20573
+ if (workInProgressRootExitStatus !== RootSuspendedWithDelay) {
19890
20574
  workInProgressRootExitStatus = RootErrored;
19891
20575
  }
19892
20576
  } // Called during render to determine if anything has suspended.
@@ -19939,11 +20623,10 @@ function renderRootSync(root, lanes) {
19939
20623
 
19940
20624
  if (workInProgress !== null) {
19941
20625
  // This is a sync render, so we should have finished the whole tree.
19942
- {
19943
- throw Error(
19944
- "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue."
19945
- );
19946
- }
20626
+ throw new Error(
20627
+ "Cannot commit an incomplete root. This error is likely caused by a " +
20628
+ "bug in React. Please file an issue."
20629
+ );
19947
20630
  }
19948
20631
 
19949
20632
  workInProgressRoot = null;
@@ -20167,8 +20850,8 @@ function commitRootImpl(root, renderPriorityLevel) {
20167
20850
 
20168
20851
  flushRenderPhaseStrictModeWarningsInDEV();
20169
20852
 
20170
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
20171
- throw Error("Should not already be working.");
20853
+ if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
20854
+ throw new Error("Should not already be working.");
20172
20855
  }
20173
20856
 
20174
20857
  var finishedWork = root.finishedWork;
@@ -20190,9 +20873,10 @@ function commitRootImpl(root, renderPriorityLevel) {
20190
20873
  root.finishedWork = null;
20191
20874
  root.finishedLanes = NoLanes;
20192
20875
 
20193
- if (!(finishedWork !== root.current)) {
20194
- throw Error(
20195
- "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue."
20876
+ if (finishedWork === root.current) {
20877
+ throw new Error(
20878
+ "Cannot commit the same tree as before. This error is likely caused by " +
20879
+ "a bug in React. Please file an issue."
20196
20880
  );
20197
20881
  } // commitRoot never returns a continuation; it always finishes synchronously.
20198
20882
  // So we can clear these now to allow a new callback to be scheduled.
@@ -20306,6 +20990,15 @@ function commitRootImpl(root, renderPriorityLevel) {
20306
20990
  } // Read this again, since an effect might have updated it
20307
20991
 
20308
20992
  remainingLanes = root.pendingLanes; // Check if there's remaining work on this root
20993
+ // TODO: This is part of the `componentDidCatch` implementation. Its purpose
20994
+ // is to detect whether something might have called setState inside
20995
+ // `componentDidCatch`. The mechanism is known to be flawed because `setState`
20996
+ // inside `componentDidCatch` is itself flawed — that's why we recommend
20997
+ // `getDerivedStateFromError` instead. However, it could be improved by
20998
+ // checking if remainingLanes includes Sync work, instead of whether there's
20999
+ // any work remaining at all (which would also include stuff like Suspense
21000
+ // retries or transitions). It's been like this for a while, though, so fixing
21001
+ // it probably isn't that urgent.
20309
21002
 
20310
21003
  if (remainingLanes === NoLanes) {
20311
21004
  // If there's no remaining work, we can clear the set of already failed
@@ -20319,22 +21012,6 @@ function commitRootImpl(root, renderPriorityLevel) {
20319
21012
  }
20320
21013
  }
20321
21014
 
20322
- if (includesSomeLane(remainingLanes, SyncLane)) {
20323
- {
20324
- markNestedUpdateScheduled();
20325
- } // Count the number of times the root synchronously re-renders without
20326
- // finishing. If there are too many, it indicates an infinite update loop.
20327
-
20328
- if (root === rootWithNestedUpdates) {
20329
- nestedUpdateCount++;
20330
- } else {
20331
- nestedUpdateCount = 0;
20332
- rootWithNestedUpdates = root;
20333
- }
20334
- } else {
20335
- nestedUpdateCount = 0;
20336
- }
20337
-
20338
21015
  onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
20339
21016
 
20340
21017
  {
@@ -20365,6 +21042,24 @@ function commitRootImpl(root, renderPriorityLevel) {
20365
21042
  root.tag !== LegacyRoot
20366
21043
  ) {
20367
21044
  flushPassiveEffects();
21045
+ } // Read this again, since a passive effect might have updated it
21046
+
21047
+ remainingLanes = root.pendingLanes;
21048
+
21049
+ if (includesSomeLane(remainingLanes, SyncLane)) {
21050
+ {
21051
+ markNestedUpdateScheduled();
21052
+ } // Count the number of times the root synchronously re-renders without
21053
+ // finishing. If there are too many, it indicates an infinite update loop.
21054
+
21055
+ if (root === rootWithNestedUpdates) {
21056
+ nestedUpdateCount++;
21057
+ } else {
21058
+ nestedUpdateCount = 0;
21059
+ rootWithNestedUpdates = root;
21060
+ }
21061
+ } else {
21062
+ nestedUpdateCount = 0;
20368
21063
  } // If layout work was scheduled, flush it now.
20369
21064
 
20370
21065
  flushSyncCallbacks();
@@ -20423,8 +21118,8 @@ function flushPassiveEffectsImpl() {
20423
21118
 
20424
21119
  pendingPassiveEffectsLanes = NoLanes;
20425
21120
 
20426
- if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
20427
- throw Error("Cannot flush passive effects while already rendering.");
21121
+ if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
21122
+ throw new Error("Cannot flush passive effects while already rendering.");
20428
21123
  }
20429
21124
 
20430
21125
  var prevExecutionContext = executionContext;
@@ -20670,12 +21365,12 @@ function checkForNestedUpdates() {
20670
21365
  if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
20671
21366
  nestedUpdateCount = 0;
20672
21367
  rootWithNestedUpdates = null;
20673
-
20674
- {
20675
- throw Error(
20676
- "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops."
20677
- );
20678
- }
21368
+ throw new Error(
21369
+ "Maximum update depth exceeded. This can happen when a component " +
21370
+ "repeatedly calls setState inside componentWillUpdate or " +
21371
+ "componentDidUpdate. React limits the number of nested updates to " +
21372
+ "prevent infinite loops."
21373
+ );
20679
21374
  }
20680
21375
 
20681
21376
  {
@@ -20881,7 +21576,7 @@ var beginWork$1;
20881
21576
  originalError._suppressLogging = true;
20882
21577
  }
20883
21578
  } // We always throw the original error in case the second render pass is not idempotent.
20884
- // This can happen if a memoized function or CommonJS module doesn't throw after first invokation.
21579
+ // This can happen if a memoized function or CommonJS module doesn't throw after first invocation.
20885
21580
 
20886
21581
  throw originalError;
20887
21582
  }
@@ -20990,6 +21685,7 @@ function shouldForceFlushFallbacksInDEV() {
20990
21685
  return ReactCurrentActQueue.current !== null;
20991
21686
  }
20992
21687
 
21688
+ /* eslint-disable react-internal/prod-error-codes */
20993
21689
  var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below.
20994
21690
 
20995
21691
  var failedBoundaries = null;
@@ -21883,14 +22579,11 @@ function createFiberFromTypeAndProps(
21883
22579
  }
21884
22580
  }
21885
22581
 
21886
- {
21887
- throw Error(
21888
- "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " +
21889
- (type == null ? type : typeof type) +
21890
- "." +
21891
- info
21892
- );
21893
- }
22582
+ throw new Error(
22583
+ "Element type is invalid: expected a string (for built-in " +
22584
+ "components) or a class/function (for composite components) " +
22585
+ ("but got: " + (type == null ? type : typeof type) + "." + info)
22586
+ );
21894
22587
  }
21895
22588
  }
21896
22589
  }
@@ -22072,7 +22765,7 @@ function FiberRootNode(containerInfo, tag, hydrate) {
22072
22765
  this.timeoutHandle = noTimeout;
22073
22766
  this.context = null;
22074
22767
  this.pendingContext = null;
22075
- this.hydrate = hydrate;
22768
+ this.isDehydrated = hydrate;
22076
22769
  this.callbackNode = null;
22077
22770
  this.callbackPriority = NoLane;
22078
22771
  this.eventTimes = createLaneMap(NoLanes);
@@ -22103,11 +22796,11 @@ function FiberRootNode(containerInfo, tag, hydrate) {
22103
22796
  {
22104
22797
  switch (tag) {
22105
22798
  case ConcurrentRoot:
22106
- this._debugRootType = "createRoot()";
22799
+ this._debugRootType = hydrate ? "hydrateRoot()" : "createRoot()";
22107
22800
  break;
22108
22801
 
22109
22802
  case LegacyRoot:
22110
- this._debugRootType = "createLegacyRoot()";
22803
+ this._debugRootType = hydrate ? "hydrate()" : "render()";
22111
22804
  break;
22112
22805
  }
22113
22806
  }
@@ -22150,6 +22843,11 @@ function createPortal(
22150
22843
  ) {
22151
22844
  var key =
22152
22845
  arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
22846
+
22847
+ {
22848
+ checkKeyStringCoercion(key);
22849
+ }
22850
+
22153
22851
  return {
22154
22852
  // This tag allow us to uniquely identify this as a React Portal
22155
22853
  $$typeof: REACT_PORTAL_TYPE,
@@ -22193,16 +22891,12 @@ function findHostInstanceWithWarning(component, methodName) {
22193
22891
 
22194
22892
  if (fiber === undefined) {
22195
22893
  if (typeof component.render === "function") {
22196
- {
22197
- throw Error("Unable to find node on an unmounted component.");
22198
- }
22894
+ throw new Error("Unable to find node on an unmounted component.");
22199
22895
  } else {
22200
- {
22201
- throw Error(
22202
- "Argument appears to not be a ReactComponent. Keys: " +
22203
- Object.keys(component)
22204
- );
22205
- }
22896
+ var keys = Object.keys(component).join(",");
22897
+ throw new Error(
22898
+ "Argument appears to not be a ReactComponent. Keys: " + keys
22899
+ );
22206
22900
  }
22207
22901
  }
22208
22902