react-dom 16.8.2 → 16.8.6

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 (34) hide show
  1. package/build-info.json +6 -6
  2. package/cjs/react-dom-server.browser.development.js +40 -13
  3. package/cjs/react-dom-server.browser.production.min.js +16 -15
  4. package/cjs/react-dom-server.node.development.js +40 -13
  5. package/cjs/react-dom-server.node.production.min.js +17 -16
  6. package/cjs/react-dom-test-utils.development.js +1 -1
  7. package/cjs/react-dom-test-utils.production.min.js +1 -1
  8. package/cjs/react-dom-unstable-fire.development.js +302 -96
  9. package/cjs/react-dom-unstable-fire.production.min.js +11 -11
  10. package/cjs/react-dom-unstable-fire.profiling.min.js +20 -19
  11. package/cjs/react-dom-unstable-fizz.browser.development.js +1 -1
  12. package/cjs/react-dom-unstable-fizz.browser.production.min.js +1 -1
  13. package/cjs/react-dom-unstable-fizz.node.development.js +1 -1
  14. package/cjs/react-dom-unstable-fizz.node.production.min.js +1 -1
  15. package/cjs/react-dom-unstable-native-dependencies.development.js +1 -1
  16. package/cjs/react-dom-unstable-native-dependencies.production.min.js +1 -1
  17. package/cjs/react-dom.development.js +302 -96
  18. package/cjs/react-dom.production.min.js +11 -11
  19. package/cjs/react-dom.profiling.min.js +20 -19
  20. package/package.json +2 -2
  21. package/umd/react-dom-server.browser.development.js +40 -13
  22. package/umd/react-dom-server.browser.production.min.js +16 -15
  23. package/umd/react-dom-test-utils.development.js +1 -1
  24. package/umd/react-dom-test-utils.production.min.js +1 -1
  25. package/umd/react-dom-unstable-fire.development.js +302 -96
  26. package/umd/react-dom-unstable-fire.production.min.js +64 -64
  27. package/umd/react-dom-unstable-fire.profiling.min.js +49 -48
  28. package/umd/react-dom-unstable-fizz.browser.development.js +1 -1
  29. package/umd/react-dom-unstable-fizz.browser.production.min.js +1 -1
  30. package/umd/react-dom-unstable-native-dependencies.development.js +1 -1
  31. package/umd/react-dom-unstable-native-dependencies.production.min.js +1 -1
  32. package/umd/react-dom.development.js +302 -96
  33. package/umd/react-dom.production.min.js +64 -64
  34. package/umd/react-dom.profiling.min.js +49 -48
@@ -1,4 +1,4 @@
1
- /** @license React v16.8.2
1
+ /** @license React v16.8.6
2
2
  * react-dom-unstable-fire.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -5435,15 +5435,29 @@ function isInDocument(node) {
5435
5435
  return node && node.ownerDocument && containsNode(node.ownerDocument.documentElement, node);
5436
5436
  }
5437
5437
 
5438
+ function isSameOriginFrame(iframe) {
5439
+ try {
5440
+ // Accessing the contentDocument of a HTMLIframeElement can cause the browser
5441
+ // to throw, e.g. if it has a cross-origin src attribute.
5442
+ // Safari will show an error in the console when the access results in "Blocked a frame with origin". e.g:
5443
+ // iframe.contentDocument.defaultView;
5444
+ // A safety way is to access one of the cross origin properties: Window or Location
5445
+ // Which might result in "SecurityError" DOM Exception and it is compatible to Safari.
5446
+ // https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl
5447
+
5448
+ return typeof iframe.contentWindow.location.href === 'string';
5449
+ } catch (err) {
5450
+ return false;
5451
+ }
5452
+ }
5453
+
5438
5454
  function getActiveElementDeep() {
5439
5455
  var win = window;
5440
5456
  var element = getActiveElement();
5441
5457
  while (element instanceof win.HTMLIFrameElement) {
5442
- // Accessing the contentDocument of a HTMLIframeElement can cause the browser
5443
- // to throw, e.g. if it has a cross-origin src attribute
5444
- try {
5445
- win = element.contentDocument.defaultView;
5446
- } catch (e) {
5458
+ if (isSameOriginFrame(element)) {
5459
+ win = element.contentWindow;
5460
+ } else {
5447
5461
  return element;
5448
5462
  }
5449
5463
  element = getActiveElement(win.document);
@@ -7733,14 +7747,25 @@ function createElement(type, props, rootContainerElement, parentNamespace) {
7733
7747
  // See discussion in https://github.com/facebook/react/pull/6896
7734
7748
  // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
7735
7749
  domElement = ownerDocument.createElement(type);
7736
- // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple`
7737
- // attribute on `select`s needs to be added before `option`s are inserted. This prevents
7738
- // a bug where the `select` does not scroll to the correct option because singular
7739
- // `select` elements automatically pick the first item.
7750
+ // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple` and `size`
7751
+ // attributes on `select`s needs to be added before `option`s are inserted.
7752
+ // This prevents:
7753
+ // - a bug where the `select` does not scroll to the correct option because singular
7754
+ // `select` elements automatically pick the first item #13222
7755
+ // - a bug where the `select` set the first item as selected despite the `size` attribute #14239
7740
7756
  // See https://github.com/facebook/react/issues/13222
7741
- if (type === 'select' && props.multiple) {
7757
+ // and https://github.com/facebook/react/issues/14239
7758
+ if (type === 'select') {
7742
7759
  var node = domElement;
7743
- node.multiple = true;
7760
+ if (props.multiple) {
7761
+ node.multiple = true;
7762
+ } else if (props.size) {
7763
+ // Setting a size greater than 1 causes a select to behave like `multiple=true`, where
7764
+ // it is possible that no option is selected.
7765
+ //
7766
+ // This is only necessary when a select in "single selection mode".
7767
+ node.size = props.size;
7768
+ }
7744
7769
  }
7745
7770
  }
7746
7771
  } else {
@@ -10127,6 +10152,7 @@ function FiberNode(tag, pendingProps, key, mode) {
10127
10152
  this._debugSource = null;
10128
10153
  this._debugOwner = null;
10129
10154
  this._debugIsCurrentlyTiming = false;
10155
+ this._debugHookTypes = null;
10130
10156
  if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
10131
10157
  Object.preventExtensions(this);
10132
10158
  }
@@ -10194,6 +10220,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
10194
10220
  workInProgress._debugID = current._debugID;
10195
10221
  workInProgress._debugSource = current._debugSource;
10196
10222
  workInProgress._debugOwner = current._debugOwner;
10223
+ workInProgress._debugHookTypes = current._debugHookTypes;
10197
10224
  }
10198
10225
 
10199
10226
  workInProgress.alternate = current;
@@ -10461,6 +10488,7 @@ function assignFiberPropertiesInDEV(target, source) {
10461
10488
  target._debugSource = source._debugSource;
10462
10489
  target._debugOwner = source._debugOwner;
10463
10490
  target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
10491
+ target._debugHookTypes = source._debugHookTypes;
10464
10492
  return target;
10465
10493
  }
10466
10494
 
@@ -11425,14 +11453,35 @@ function constructClassInstance(workInProgress, ctor, props, renderExpirationTim
11425
11453
  var unmaskedContext = emptyContextObject;
11426
11454
  var context = null;
11427
11455
  var contextType = ctor.contextType;
11428
- if (typeof contextType === 'object' && contextType !== null) {
11429
- {
11430
- if (contextType.$$typeof !== REACT_CONTEXT_TYPE && !didWarnAboutInvalidateContextType.has(ctor)) {
11456
+
11457
+ {
11458
+ if ('contextType' in ctor) {
11459
+ var isValid =
11460
+ // Allow null for conditional declaration
11461
+ contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer>
11462
+
11463
+ if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
11431
11464
  didWarnAboutInvalidateContextType.add(ctor);
11432
- warningWithoutStack$1(false, '%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext(). ' + 'Did you accidentally pass the Context.Provider instead?', getComponentName(ctor) || 'Component');
11465
+
11466
+ var addendum = '';
11467
+ if (contextType === undefined) {
11468
+ addendum = ' However, it is set to undefined. ' + 'This can be caused by a typo or by mixing up named and default imports. ' + 'This can also happen due to a circular dependency, so ' + 'try moving the createContext() call to a separate file.';
11469
+ } else if (typeof contextType !== 'object') {
11470
+ addendum = ' However, it is set to a ' + typeof contextType + '.';
11471
+ } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
11472
+ addendum = ' Did you accidentally pass the Context.Provider instead?';
11473
+ } else if (contextType._context !== undefined) {
11474
+ // <Context.Consumer>
11475
+ addendum = ' Did you accidentally pass the Context.Consumer instead?';
11476
+ } else {
11477
+ addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
11478
+ }
11479
+ warningWithoutStack$1(false, '%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum);
11433
11480
  }
11434
11481
  }
11482
+ }
11435
11483
 
11484
+ if (typeof contextType === 'object' && contextType !== null) {
11436
11485
  context = readContext(contextType);
11437
11486
  } else {
11438
11487
  unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
@@ -12859,7 +12908,6 @@ var currentlyRenderingFiber$1 = null;
12859
12908
  // current hook list is the list that belongs to the current fiber. The
12860
12909
  // work-in-progress hook list is a new list that will be added to the
12861
12910
  // work-in-progress fiber.
12862
- var firstCurrentHook = null;
12863
12911
  var currentHook = null;
12864
12912
  var nextCurrentHook = null;
12865
12913
  var firstWorkInProgressHook = null;
@@ -12889,45 +12937,73 @@ var RE_RENDER_LIMIT = 25;
12889
12937
  // In DEV, this is the name of the currently executing primitive hook
12890
12938
  var currentHookNameInDev = null;
12891
12939
 
12892
- function warnOnHookMismatchInDev() {
12940
+ // In DEV, this list ensures that hooks are called in the same order between renders.
12941
+ // The list stores the order of hooks used during the initial render (mount).
12942
+ // Subsequent renders (updates) reference this list.
12943
+ var hookTypesDev = null;
12944
+ var hookTypesUpdateIndexDev = -1;
12945
+
12946
+ function mountHookTypesDev() {
12947
+ {
12948
+ var hookName = currentHookNameInDev;
12949
+
12950
+ if (hookTypesDev === null) {
12951
+ hookTypesDev = [hookName];
12952
+ } else {
12953
+ hookTypesDev.push(hookName);
12954
+ }
12955
+ }
12956
+ }
12957
+
12958
+ function updateHookTypesDev() {
12959
+ {
12960
+ var hookName = currentHookNameInDev;
12961
+
12962
+ if (hookTypesDev !== null) {
12963
+ hookTypesUpdateIndexDev++;
12964
+ if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
12965
+ warnOnHookMismatchInDev(hookName);
12966
+ }
12967
+ }
12968
+ }
12969
+ }
12970
+
12971
+ function warnOnHookMismatchInDev(currentHookName) {
12893
12972
  {
12894
12973
  var componentName = getComponentName(currentlyRenderingFiber$1.type);
12895
12974
  if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
12896
12975
  didWarnAboutMismatchedHooksForComponent.add(componentName);
12897
12976
 
12898
- var secondColumnStart = 22;
12977
+ if (hookTypesDev !== null) {
12978
+ var table = '';
12899
12979
 
12900
- var table = '';
12901
- var prevHook = firstCurrentHook;
12902
- var nextHook = firstWorkInProgressHook;
12903
- var n = 1;
12904
- while (prevHook !== null && nextHook !== null) {
12905
- var oldHookName = prevHook._debugType;
12906
- var newHookName = nextHook._debugType;
12980
+ var secondColumnStart = 30;
12907
12981
 
12908
- var row = n + '. ' + oldHookName;
12982
+ for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
12983
+ var oldHookName = hookTypesDev[i];
12984
+ var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
12909
12985
 
12910
- // Extra space so second column lines up
12911
- // lol @ IE not supporting String#repeat
12912
- while (row.length < secondColumnStart) {
12913
- row += ' ';
12914
- }
12986
+ var row = i + 1 + '. ' + oldHookName;
12915
12987
 
12916
- row += newHookName + '\n';
12988
+ // Extra space so second column lines up
12989
+ // lol @ IE not supporting String#repeat
12990
+ while (row.length < secondColumnStart) {
12991
+ row += ' ';
12992
+ }
12917
12993
 
12918
- table += row;
12919
- prevHook = prevHook.next;
12920
- nextHook = nextHook.next;
12921
- n++;
12922
- }
12994
+ row += newHookName + '\n';
12923
12995
 
12924
- warning$1(false, 'React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' -------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table);
12996
+ table += row;
12997
+ }
12998
+
12999
+ warning$1(false, 'React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table);
13000
+ }
12925
13001
  }
12926
13002
  }
12927
13003
  }
12928
13004
 
12929
13005
  function throwInvalidHookError() {
12930
- invariant(false, 'Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)');
13006
+ invariant(false, '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://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.');
12931
13007
  }
12932
13008
 
12933
13009
  function areHookInputsEqual(nextDeps, prevDeps) {
@@ -12957,7 +13033,12 @@ function areHookInputsEqual(nextDeps, prevDeps) {
12957
13033
  function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
12958
13034
  renderExpirationTime = nextRenderExpirationTime;
12959
13035
  currentlyRenderingFiber$1 = workInProgress;
12960
- firstCurrentHook = nextCurrentHook = current !== null ? current.memoizedState : null;
13036
+ nextCurrentHook = current !== null ? current.memoizedState : null;
13037
+
13038
+ {
13039
+ hookTypesDev = current !== null ? current._debugHookTypes : null;
13040
+ hookTypesUpdateIndexDev = -1;
13041
+ }
12961
13042
 
12962
13043
  // The following should have already been reset
12963
13044
  // currentHook = null;
@@ -12971,8 +13052,26 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12971
13052
  // numberOfReRenders = 0;
12972
13053
  // sideEffectTag = 0;
12973
13054
 
13055
+ // TODO Warn if no hooks are used at all during mount, then some are used during update.
13056
+ // Currently we will identify the update render as a mount because nextCurrentHook === null.
13057
+ // This is tricky because it's valid for certain types of components (e.g. React.lazy)
13058
+
13059
+ // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used.
13060
+ // Non-stateful hooks (e.g. context) don't get added to memoizedState,
13061
+ // so nextCurrentHook would be null during updates and mounts.
12974
13062
  {
12975
- ReactCurrentDispatcher$1.current = nextCurrentHook === null ? HooksDispatcherOnMountInDEV : HooksDispatcherOnUpdateInDEV;
13063
+ if (nextCurrentHook !== null) {
13064
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
13065
+ } else if (hookTypesDev !== null) {
13066
+ // This dispatcher handles an edge case where a component is updating,
13067
+ // but no stateful hooks have been used.
13068
+ // We want to match the production code behavior (which will use HooksDispatcherOnMount),
13069
+ // but with the extra DEV validation to ensure hooks ordering hasn't changed.
13070
+ // This dispatcher does that.
13071
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
13072
+ } else {
13073
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
13074
+ }
12976
13075
  }
12977
13076
 
12978
13077
  var children = Component(props, refOrContext);
@@ -12983,13 +13082,18 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12983
13082
  numberOfReRenders += 1;
12984
13083
 
12985
13084
  // Start over from the beginning of the list
12986
- firstCurrentHook = nextCurrentHook = current !== null ? current.memoizedState : null;
13085
+ nextCurrentHook = current !== null ? current.memoizedState : null;
12987
13086
  nextWorkInProgressHook = firstWorkInProgressHook;
12988
13087
 
12989
13088
  currentHook = null;
12990
13089
  workInProgressHook = null;
12991
13090
  componentUpdateQueue = null;
12992
13091
 
13092
+ {
13093
+ // Also validate hook order for cascading updates.
13094
+ hookTypesUpdateIndexDev = -1;
13095
+ }
13096
+
12993
13097
  ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
12994
13098
 
12995
13099
  children = Component(props, refOrContext);
@@ -12999,10 +13103,6 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12999
13103
  numberOfReRenders = 0;
13000
13104
  }
13001
13105
 
13002
- {
13003
- currentHookNameInDev = null;
13004
- }
13005
-
13006
13106
  // We can assume the previous dispatcher is always this one, since we set it
13007
13107
  // at the beginning of the render phase and there's no re-entrancy.
13008
13108
  ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
@@ -13014,18 +13114,29 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
13014
13114
  renderedWork.updateQueue = componentUpdateQueue;
13015
13115
  renderedWork.effectTag |= sideEffectTag;
13016
13116
 
13117
+ {
13118
+ renderedWork._debugHookTypes = hookTypesDev;
13119
+ }
13120
+
13121
+ // This check uses currentHook so that it works the same in DEV and prod bundles.
13122
+ // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
13017
13123
  var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
13018
13124
 
13019
13125
  renderExpirationTime = NoWork;
13020
13126
  currentlyRenderingFiber$1 = null;
13021
13127
 
13022
- firstCurrentHook = null;
13023
13128
  currentHook = null;
13024
13129
  nextCurrentHook = null;
13025
13130
  firstWorkInProgressHook = null;
13026
13131
  workInProgressHook = null;
13027
13132
  nextWorkInProgressHook = null;
13028
13133
 
13134
+ {
13135
+ currentHookNameInDev = null;
13136
+ hookTypesDev = null;
13137
+ hookTypesUpdateIndexDev = -1;
13138
+ }
13139
+
13029
13140
  remainingExpirationTime = NoWork;
13030
13141
  componentUpdateQueue = null;
13031
13142
  sideEffectTag = 0;
@@ -13059,21 +13170,23 @@ function resetHooks() {
13059
13170
  renderExpirationTime = NoWork;
13060
13171
  currentlyRenderingFiber$1 = null;
13061
13172
 
13062
- firstCurrentHook = null;
13063
13173
  currentHook = null;
13064
13174
  nextCurrentHook = null;
13065
13175
  firstWorkInProgressHook = null;
13066
13176
  workInProgressHook = null;
13067
13177
  nextWorkInProgressHook = null;
13068
13178
 
13069
- remainingExpirationTime = NoWork;
13070
- componentUpdateQueue = null;
13071
- sideEffectTag = 0;
13072
-
13073
13179
  {
13180
+ hookTypesDev = null;
13181
+ hookTypesUpdateIndexDev = -1;
13182
+
13074
13183
  currentHookNameInDev = null;
13075
13184
  }
13076
13185
 
13186
+ remainingExpirationTime = NoWork;
13187
+ componentUpdateQueue = null;
13188
+ sideEffectTag = 0;
13189
+
13077
13190
  didScheduleRenderPhaseUpdate = false;
13078
13191
  renderPhaseUpdates = null;
13079
13192
  numberOfReRenders = 0;
@@ -13090,9 +13203,6 @@ function mountWorkInProgressHook() {
13090
13203
  next: null
13091
13204
  };
13092
13205
 
13093
- {
13094
- hook._debugType = currentHookNameInDev;
13095
- }
13096
13206
  if (workInProgressHook === null) {
13097
13207
  // This is the first hook in the list
13098
13208
  firstWorkInProgressHook = workInProgressHook = hook;
@@ -13139,13 +13249,6 @@ function updateWorkInProgressHook() {
13139
13249
  workInProgressHook = workInProgressHook.next = newHook;
13140
13250
  }
13141
13251
  nextCurrentHook = currentHook.next;
13142
-
13143
- {
13144
- newHook._debugType = currentHookNameInDev;
13145
- if (currentHookNameInDev !== currentHook._debugType) {
13146
- warnOnHookMismatchInDev();
13147
- }
13148
- }
13149
13252
  }
13150
13253
  return workInProgressHook;
13151
13254
  }
@@ -13160,20 +13263,6 @@ function basicStateReducer(state, action) {
13160
13263
  return typeof action === 'function' ? action(state) : action;
13161
13264
  }
13162
13265
 
13163
- function mountContext(context, observedBits) {
13164
- {
13165
- mountWorkInProgressHook();
13166
- }
13167
- return readContext(context, observedBits);
13168
- }
13169
-
13170
- function updateContext(context, observedBits) {
13171
- {
13172
- updateWorkInProgressHook();
13173
- }
13174
- return readContext(context, observedBits);
13175
- }
13176
-
13177
13266
  function mountReducer(reducer, initialArg, init) {
13178
13267
  var hook = mountWorkInProgressHook();
13179
13268
  var initialState = void 0;
@@ -13186,8 +13275,8 @@ function mountReducer(reducer, initialArg, init) {
13186
13275
  var queue = hook.queue = {
13187
13276
  last: null,
13188
13277
  dispatch: null,
13189
- eagerReducer: reducer,
13190
- eagerState: initialState
13278
+ lastRenderedReducer: reducer,
13279
+ lastRenderedState: initialState
13191
13280
  };
13192
13281
  var dispatch = queue.dispatch = dispatchAction.bind(null,
13193
13282
  // Flow doesn't know this is non-null, but we do.
@@ -13200,6 +13289,8 @@ function updateReducer(reducer, initialArg, init) {
13200
13289
  var queue = hook.queue;
13201
13290
  !(queue !== null) ? invariant(false, 'Should have a queue. This is likely a bug in React. Please file an issue.') : void 0;
13202
13291
 
13292
+ queue.lastRenderedReducer = reducer;
13293
+
13203
13294
  if (numberOfReRenders > 0) {
13204
13295
  // This is a re-render. Apply the new render phase updates to the previous
13205
13296
  var _dispatch = queue.dispatch;
@@ -13226,7 +13317,6 @@ function updateReducer(reducer, initialArg, init) {
13226
13317
  }
13227
13318
 
13228
13319
  hook.memoizedState = newState;
13229
-
13230
13320
  // Don't persist the state accumlated from the render phase updates to
13231
13321
  // the base state unless the queue is empty.
13232
13322
  // TODO: Not sure if this is the desired semantics, but it's what we
@@ -13235,6 +13325,8 @@ function updateReducer(reducer, initialArg, init) {
13235
13325
  hook.baseState = newState;
13236
13326
  }
13237
13327
 
13328
+ queue.lastRenderedState = newState;
13329
+
13238
13330
  return [newState, _dispatch];
13239
13331
  }
13240
13332
  }
@@ -13312,8 +13404,7 @@ function updateReducer(reducer, initialArg, init) {
13312
13404
  hook.baseUpdate = newBaseUpdate;
13313
13405
  hook.baseState = newBaseState;
13314
13406
 
13315
- queue.eagerReducer = reducer;
13316
- queue.eagerState = _newState;
13407
+ queue.lastRenderedState = _newState;
13317
13408
  }
13318
13409
 
13319
13410
  var dispatch = queue.dispatch;
@@ -13329,8 +13420,8 @@ function mountState(initialState) {
13329
13420
  var queue = hook.queue = {
13330
13421
  last: null,
13331
13422
  dispatch: null,
13332
- eagerReducer: basicStateReducer,
13333
- eagerState: initialState
13423
+ lastRenderedReducer: basicStateReducer,
13424
+ lastRenderedState: initialState
13334
13425
  };
13335
13426
  var dispatch = queue.dispatch = dispatchAction.bind(null,
13336
13427
  // Flow doesn't know this is non-null, but we do.
@@ -13607,21 +13698,21 @@ function dispatchAction(fiber, queue, action) {
13607
13698
  // The queue is currently empty, which means we can eagerly compute the
13608
13699
  // next state before entering the render phase. If the new state is the
13609
13700
  // same as the current state, we may be able to bail out entirely.
13610
- var _eagerReducer = queue.eagerReducer;
13611
- if (_eagerReducer !== null) {
13701
+ var _lastRenderedReducer = queue.lastRenderedReducer;
13702
+ if (_lastRenderedReducer !== null) {
13612
13703
  var prevDispatcher = void 0;
13613
13704
  {
13614
13705
  prevDispatcher = ReactCurrentDispatcher$1.current;
13615
13706
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13616
13707
  }
13617
13708
  try {
13618
- var currentState = queue.eagerState;
13619
- var _eagerState = _eagerReducer(currentState, action);
13709
+ var currentState = queue.lastRenderedState;
13710
+ var _eagerState = _lastRenderedReducer(currentState, action);
13620
13711
  // Stash the eagerly computed state, and the reducer used to compute
13621
13712
  // it, on the update object. If the reducer hasn't changed by the
13622
13713
  // time we enter the render phase, then the eager state can be used
13623
13714
  // without calling the reducer again.
13624
- _update2.eagerReducer = _eagerReducer;
13715
+ _update2.eagerReducer = _lastRenderedReducer;
13625
13716
  _update2.eagerState = _eagerState;
13626
13717
  if (is(_eagerState, currentState)) {
13627
13718
  // Fast path. We can bail out without scheduling React to re-render.
@@ -13664,6 +13755,7 @@ var ContextOnlyDispatcher = {
13664
13755
  };
13665
13756
 
13666
13757
  var HooksDispatcherOnMountInDEV = null;
13758
+ var HooksDispatcherOnMountWithHookTypesInDEV = null;
13667
13759
  var HooksDispatcherOnUpdateInDEV = null;
13668
13760
  var InvalidNestedHooksDispatcherOnMountInDEV = null;
13669
13761
  var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
@@ -13683,26 +13775,106 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13683
13775
  },
13684
13776
  useCallback: function (callback, deps) {
13685
13777
  currentHookNameInDev = 'useCallback';
13778
+ mountHookTypesDev();
13779
+ return mountCallback(callback, deps);
13780
+ },
13781
+ useContext: function (context, observedBits) {
13782
+ currentHookNameInDev = 'useContext';
13783
+ mountHookTypesDev();
13784
+ return readContext(context, observedBits);
13785
+ },
13786
+ useEffect: function (create, deps) {
13787
+ currentHookNameInDev = 'useEffect';
13788
+ mountHookTypesDev();
13789
+ return mountEffect(create, deps);
13790
+ },
13791
+ useImperativeHandle: function (ref, create, deps) {
13792
+ currentHookNameInDev = 'useImperativeHandle';
13793
+ mountHookTypesDev();
13794
+ return mountImperativeHandle(ref, create, deps);
13795
+ },
13796
+ useLayoutEffect: function (create, deps) {
13797
+ currentHookNameInDev = 'useLayoutEffect';
13798
+ mountHookTypesDev();
13799
+ return mountLayoutEffect(create, deps);
13800
+ },
13801
+ useMemo: function (create, deps) {
13802
+ currentHookNameInDev = 'useMemo';
13803
+ mountHookTypesDev();
13804
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
13805
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13806
+ try {
13807
+ return mountMemo(create, deps);
13808
+ } finally {
13809
+ ReactCurrentDispatcher$1.current = prevDispatcher;
13810
+ }
13811
+ },
13812
+ useReducer: function (reducer, initialArg, init) {
13813
+ currentHookNameInDev = 'useReducer';
13814
+ mountHookTypesDev();
13815
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
13816
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13817
+ try {
13818
+ return mountReducer(reducer, initialArg, init);
13819
+ } finally {
13820
+ ReactCurrentDispatcher$1.current = prevDispatcher;
13821
+ }
13822
+ },
13823
+ useRef: function (initialValue) {
13824
+ currentHookNameInDev = 'useRef';
13825
+ mountHookTypesDev();
13826
+ return mountRef(initialValue);
13827
+ },
13828
+ useState: function (initialState) {
13829
+ currentHookNameInDev = 'useState';
13830
+ mountHookTypesDev();
13831
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
13832
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13833
+ try {
13834
+ return mountState(initialState);
13835
+ } finally {
13836
+ ReactCurrentDispatcher$1.current = prevDispatcher;
13837
+ }
13838
+ },
13839
+ useDebugValue: function (value, formatterFn) {
13840
+ currentHookNameInDev = 'useDebugValue';
13841
+ mountHookTypesDev();
13842
+ return mountDebugValue(value, formatterFn);
13843
+ }
13844
+ };
13845
+
13846
+ HooksDispatcherOnMountWithHookTypesInDEV = {
13847
+ readContext: function (context, observedBits) {
13848
+ return readContext(context, observedBits);
13849
+ },
13850
+ useCallback: function (callback, deps) {
13851
+ currentHookNameInDev = 'useCallback';
13852
+ updateHookTypesDev();
13686
13853
  return mountCallback(callback, deps);
13687
13854
  },
13688
13855
  useContext: function (context, observedBits) {
13689
13856
  currentHookNameInDev = 'useContext';
13690
- return mountContext(context, observedBits);
13857
+ updateHookTypesDev();
13858
+ return readContext(context, observedBits);
13691
13859
  },
13692
13860
  useEffect: function (create, deps) {
13693
13861
  currentHookNameInDev = 'useEffect';
13862
+ updateHookTypesDev();
13694
13863
  return mountEffect(create, deps);
13695
13864
  },
13696
13865
  useImperativeHandle: function (ref, create, deps) {
13697
13866
  currentHookNameInDev = 'useImperativeHandle';
13867
+ updateHookTypesDev();
13698
13868
  return mountImperativeHandle(ref, create, deps);
13699
13869
  },
13700
13870
  useLayoutEffect: function (create, deps) {
13701
13871
  currentHookNameInDev = 'useLayoutEffect';
13872
+ updateHookTypesDev();
13702
13873
  return mountLayoutEffect(create, deps);
13703
13874
  },
13704
13875
  useMemo: function (create, deps) {
13705
13876
  currentHookNameInDev = 'useMemo';
13877
+ updateHookTypesDev();
13706
13878
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13707
13879
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13708
13880
  try {
@@ -13713,6 +13885,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13713
13885
  },
13714
13886
  useReducer: function (reducer, initialArg, init) {
13715
13887
  currentHookNameInDev = 'useReducer';
13888
+ updateHookTypesDev();
13716
13889
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13717
13890
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13718
13891
  try {
@@ -13723,10 +13896,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13723
13896
  },
13724
13897
  useRef: function (initialValue) {
13725
13898
  currentHookNameInDev = 'useRef';
13899
+ updateHookTypesDev();
13726
13900
  return mountRef(initialValue);
13727
13901
  },
13728
13902
  useState: function (initialState) {
13729
13903
  currentHookNameInDev = 'useState';
13904
+ updateHookTypesDev();
13730
13905
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13731
13906
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13732
13907
  try {
@@ -13737,6 +13912,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13737
13912
  },
13738
13913
  useDebugValue: function (value, formatterFn) {
13739
13914
  currentHookNameInDev = 'useDebugValue';
13915
+ updateHookTypesDev();
13740
13916
  return mountDebugValue(value, formatterFn);
13741
13917
  }
13742
13918
  };
@@ -13747,26 +13923,32 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13747
13923
  },
13748
13924
  useCallback: function (callback, deps) {
13749
13925
  currentHookNameInDev = 'useCallback';
13926
+ updateHookTypesDev();
13750
13927
  return updateCallback(callback, deps);
13751
13928
  },
13752
13929
  useContext: function (context, observedBits) {
13753
13930
  currentHookNameInDev = 'useContext';
13754
- return updateContext(context, observedBits);
13931
+ updateHookTypesDev();
13932
+ return readContext(context, observedBits);
13755
13933
  },
13756
13934
  useEffect: function (create, deps) {
13757
13935
  currentHookNameInDev = 'useEffect';
13936
+ updateHookTypesDev();
13758
13937
  return updateEffect(create, deps);
13759
13938
  },
13760
13939
  useImperativeHandle: function (ref, create, deps) {
13761
13940
  currentHookNameInDev = 'useImperativeHandle';
13941
+ updateHookTypesDev();
13762
13942
  return updateImperativeHandle(ref, create, deps);
13763
13943
  },
13764
13944
  useLayoutEffect: function (create, deps) {
13765
13945
  currentHookNameInDev = 'useLayoutEffect';
13946
+ updateHookTypesDev();
13766
13947
  return updateLayoutEffect(create, deps);
13767
13948
  },
13768
13949
  useMemo: function (create, deps) {
13769
13950
  currentHookNameInDev = 'useMemo';
13951
+ updateHookTypesDev();
13770
13952
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13771
13953
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13772
13954
  try {
@@ -13777,6 +13959,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13777
13959
  },
13778
13960
  useReducer: function (reducer, initialArg, init) {
13779
13961
  currentHookNameInDev = 'useReducer';
13962
+ updateHookTypesDev();
13780
13963
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13781
13964
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13782
13965
  try {
@@ -13787,10 +13970,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13787
13970
  },
13788
13971
  useRef: function (initialValue) {
13789
13972
  currentHookNameInDev = 'useRef';
13973
+ updateHookTypesDev();
13790
13974
  return updateRef(initialValue);
13791
13975
  },
13792
13976
  useState: function (initialState) {
13793
13977
  currentHookNameInDev = 'useState';
13978
+ updateHookTypesDev();
13794
13979
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13795
13980
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13796
13981
  try {
@@ -13801,6 +13986,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13801
13986
  },
13802
13987
  useDebugValue: function (value, formatterFn) {
13803
13988
  currentHookNameInDev = 'useDebugValue';
13989
+ updateHookTypesDev();
13804
13990
  return updateDebugValue(value, formatterFn);
13805
13991
  }
13806
13992
  };
@@ -13813,31 +13999,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13813
13999
  useCallback: function (callback, deps) {
13814
14000
  currentHookNameInDev = 'useCallback';
13815
14001
  warnInvalidHookAccess();
14002
+ mountHookTypesDev();
13816
14003
  return mountCallback(callback, deps);
13817
14004
  },
13818
14005
  useContext: function (context, observedBits) {
13819
14006
  currentHookNameInDev = 'useContext';
13820
14007
  warnInvalidHookAccess();
13821
- return mountContext(context, observedBits);
14008
+ mountHookTypesDev();
14009
+ return readContext(context, observedBits);
13822
14010
  },
13823
14011
  useEffect: function (create, deps) {
13824
14012
  currentHookNameInDev = 'useEffect';
13825
14013
  warnInvalidHookAccess();
14014
+ mountHookTypesDev();
13826
14015
  return mountEffect(create, deps);
13827
14016
  },
13828
14017
  useImperativeHandle: function (ref, create, deps) {
13829
14018
  currentHookNameInDev = 'useImperativeHandle';
13830
14019
  warnInvalidHookAccess();
14020
+ mountHookTypesDev();
13831
14021
  return mountImperativeHandle(ref, create, deps);
13832
14022
  },
13833
14023
  useLayoutEffect: function (create, deps) {
13834
14024
  currentHookNameInDev = 'useLayoutEffect';
13835
14025
  warnInvalidHookAccess();
14026
+ mountHookTypesDev();
13836
14027
  return mountLayoutEffect(create, deps);
13837
14028
  },
13838
14029
  useMemo: function (create, deps) {
13839
14030
  currentHookNameInDev = 'useMemo';
13840
14031
  warnInvalidHookAccess();
14032
+ mountHookTypesDev();
13841
14033
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13842
14034
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13843
14035
  try {
@@ -13849,6 +14041,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13849
14041
  useReducer: function (reducer, initialArg, init) {
13850
14042
  currentHookNameInDev = 'useReducer';
13851
14043
  warnInvalidHookAccess();
14044
+ mountHookTypesDev();
13852
14045
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13853
14046
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13854
14047
  try {
@@ -13860,11 +14053,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13860
14053
  useRef: function (initialValue) {
13861
14054
  currentHookNameInDev = 'useRef';
13862
14055
  warnInvalidHookAccess();
14056
+ mountHookTypesDev();
13863
14057
  return mountRef(initialValue);
13864
14058
  },
13865
14059
  useState: function (initialState) {
13866
14060
  currentHookNameInDev = 'useState';
13867
14061
  warnInvalidHookAccess();
14062
+ mountHookTypesDev();
13868
14063
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13869
14064
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13870
14065
  try {
@@ -13876,6 +14071,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13876
14071
  useDebugValue: function (value, formatterFn) {
13877
14072
  currentHookNameInDev = 'useDebugValue';
13878
14073
  warnInvalidHookAccess();
14074
+ mountHookTypesDev();
13879
14075
  return mountDebugValue(value, formatterFn);
13880
14076
  }
13881
14077
  };
@@ -13888,31 +14084,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13888
14084
  useCallback: function (callback, deps) {
13889
14085
  currentHookNameInDev = 'useCallback';
13890
14086
  warnInvalidHookAccess();
14087
+ updateHookTypesDev();
13891
14088
  return updateCallback(callback, deps);
13892
14089
  },
13893
14090
  useContext: function (context, observedBits) {
13894
14091
  currentHookNameInDev = 'useContext';
13895
14092
  warnInvalidHookAccess();
13896
- return updateContext(context, observedBits);
14093
+ updateHookTypesDev();
14094
+ return readContext(context, observedBits);
13897
14095
  },
13898
14096
  useEffect: function (create, deps) {
13899
14097
  currentHookNameInDev = 'useEffect';
13900
14098
  warnInvalidHookAccess();
14099
+ updateHookTypesDev();
13901
14100
  return updateEffect(create, deps);
13902
14101
  },
13903
14102
  useImperativeHandle: function (ref, create, deps) {
13904
14103
  currentHookNameInDev = 'useImperativeHandle';
13905
14104
  warnInvalidHookAccess();
14105
+ updateHookTypesDev();
13906
14106
  return updateImperativeHandle(ref, create, deps);
13907
14107
  },
13908
14108
  useLayoutEffect: function (create, deps) {
13909
14109
  currentHookNameInDev = 'useLayoutEffect';
13910
14110
  warnInvalidHookAccess();
14111
+ updateHookTypesDev();
13911
14112
  return updateLayoutEffect(create, deps);
13912
14113
  },
13913
14114
  useMemo: function (create, deps) {
13914
14115
  currentHookNameInDev = 'useMemo';
13915
14116
  warnInvalidHookAccess();
14117
+ updateHookTypesDev();
13916
14118
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13917
14119
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13918
14120
  try {
@@ -13924,6 +14126,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13924
14126
  useReducer: function (reducer, initialArg, init) {
13925
14127
  currentHookNameInDev = 'useReducer';
13926
14128
  warnInvalidHookAccess();
14129
+ updateHookTypesDev();
13927
14130
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13928
14131
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13929
14132
  try {
@@ -13935,11 +14138,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13935
14138
  useRef: function (initialValue) {
13936
14139
  currentHookNameInDev = 'useRef';
13937
14140
  warnInvalidHookAccess();
14141
+ updateHookTypesDev();
13938
14142
  return updateRef(initialValue);
13939
14143
  },
13940
14144
  useState: function (initialState) {
13941
14145
  currentHookNameInDev = 'useState';
13942
14146
  warnInvalidHookAccess();
14147
+ updateHookTypesDev();
13943
14148
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13944
14149
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13945
14150
  try {
@@ -13951,6 +14156,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13951
14156
  useDebugValue: function (value, formatterFn) {
13952
14157
  currentHookNameInDev = 'useDebugValue';
13953
14158
  warnInvalidHookAccess();
14159
+ updateHookTypesDev();
13954
14160
  return updateDebugValue(value, formatterFn);
13955
14161
  }
13956
14162
  };
@@ -17222,11 +17428,11 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) {
17222
17428
  if (_destroy === null) {
17223
17429
  addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
17224
17430
  } else if (typeof _destroy.then === 'function') {
17225
- addendum = '\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. ' + 'Instead, you may write an async function separately ' + 'and then call it from inside the effect:\n\n' + 'async function fetchComment(commentId) {\n' + ' // You can await here\n' + '}\n\n' + 'useEffect(() => {\n' + ' fetchComment(commentId);\n' + '}, [commentId]);\n\n' + 'In the future, React will provide a more idiomatic solution for data fetching ' + "that doesn't involve writing effects manually.";
17431
+ addendum = '\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. ' + 'Instead, write the async function inside your effect ' + 'and call it immediately:\n\n' + 'useEffect(() => {\n' + ' async function fetchData() {\n' + ' // You can await here\n' + ' const response = await MyAPI.getData(someId);\n' + ' // ...\n' + ' }\n' + ' fetchData();\n' + '}, [someId]); // Or [] if effect doesn\'t need props or state\n\n' + 'Learn more about data fetching with Hooks: https://fb.me/react-hooks-data-fetching';
17226
17432
  } else {
17227
17433
  addendum = ' You returned: ' + _destroy;
17228
17434
  }
17229
- warningWithoutStack$1(false, 'An Effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
17435
+ warningWithoutStack$1(false, 'An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
17230
17436
  }
17231
17437
  }
17232
17438
  }
@@ -20685,7 +20891,7 @@ implementation) {
20685
20891
 
20686
20892
  // TODO: this is special because it gets imported during build.
20687
20893
 
20688
- var ReactVersion = '16.8.2';
20894
+ var ReactVersion = '16.8.6';
20689
20895
 
20690
20896
  // This file is copy paste from ReactDOM with adjusted paths
20691
20897
  // and a different host config import (react-reconciler/inline.fire).