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.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 {
@@ -10123,6 +10148,7 @@ function FiberNode(tag, pendingProps, key, mode) {
10123
10148
  this._debugSource = null;
10124
10149
  this._debugOwner = null;
10125
10150
  this._debugIsCurrentlyTiming = false;
10151
+ this._debugHookTypes = null;
10126
10152
  if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
10127
10153
  Object.preventExtensions(this);
10128
10154
  }
@@ -10190,6 +10216,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
10190
10216
  workInProgress._debugID = current._debugID;
10191
10217
  workInProgress._debugSource = current._debugSource;
10192
10218
  workInProgress._debugOwner = current._debugOwner;
10219
+ workInProgress._debugHookTypes = current._debugHookTypes;
10193
10220
  }
10194
10221
 
10195
10222
  workInProgress.alternate = current;
@@ -10457,6 +10484,7 @@ function assignFiberPropertiesInDEV(target, source) {
10457
10484
  target._debugSource = source._debugSource;
10458
10485
  target._debugOwner = source._debugOwner;
10459
10486
  target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
10487
+ target._debugHookTypes = source._debugHookTypes;
10460
10488
  return target;
10461
10489
  }
10462
10490
 
@@ -11421,14 +11449,35 @@ function constructClassInstance(workInProgress, ctor, props, renderExpirationTim
11421
11449
  var unmaskedContext = emptyContextObject;
11422
11450
  var context = null;
11423
11451
  var contextType = ctor.contextType;
11424
- if (typeof contextType === 'object' && contextType !== null) {
11425
- {
11426
- if (contextType.$$typeof !== REACT_CONTEXT_TYPE && !didWarnAboutInvalidateContextType.has(ctor)) {
11452
+
11453
+ {
11454
+ if ('contextType' in ctor) {
11455
+ var isValid =
11456
+ // Allow null for conditional declaration
11457
+ contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer>
11458
+
11459
+ if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
11427
11460
  didWarnAboutInvalidateContextType.add(ctor);
11428
- 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');
11461
+
11462
+ var addendum = '';
11463
+ if (contextType === undefined) {
11464
+ 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.';
11465
+ } else if (typeof contextType !== 'object') {
11466
+ addendum = ' However, it is set to a ' + typeof contextType + '.';
11467
+ } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
11468
+ addendum = ' Did you accidentally pass the Context.Provider instead?';
11469
+ } else if (contextType._context !== undefined) {
11470
+ // <Context.Consumer>
11471
+ addendum = ' Did you accidentally pass the Context.Consumer instead?';
11472
+ } else {
11473
+ addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
11474
+ }
11475
+ warningWithoutStack$1(false, '%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum);
11429
11476
  }
11430
11477
  }
11478
+ }
11431
11479
 
11480
+ if (typeof contextType === 'object' && contextType !== null) {
11432
11481
  context = readContext(contextType);
11433
11482
  } else {
11434
11483
  unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
@@ -12855,7 +12904,6 @@ var currentlyRenderingFiber$1 = null;
12855
12904
  // current hook list is the list that belongs to the current fiber. The
12856
12905
  // work-in-progress hook list is a new list that will be added to the
12857
12906
  // work-in-progress fiber.
12858
- var firstCurrentHook = null;
12859
12907
  var currentHook = null;
12860
12908
  var nextCurrentHook = null;
12861
12909
  var firstWorkInProgressHook = null;
@@ -12885,45 +12933,73 @@ var RE_RENDER_LIMIT = 25;
12885
12933
  // In DEV, this is the name of the currently executing primitive hook
12886
12934
  var currentHookNameInDev = null;
12887
12935
 
12888
- function warnOnHookMismatchInDev() {
12936
+ // In DEV, this list ensures that hooks are called in the same order between renders.
12937
+ // The list stores the order of hooks used during the initial render (mount).
12938
+ // Subsequent renders (updates) reference this list.
12939
+ var hookTypesDev = null;
12940
+ var hookTypesUpdateIndexDev = -1;
12941
+
12942
+ function mountHookTypesDev() {
12943
+ {
12944
+ var hookName = currentHookNameInDev;
12945
+
12946
+ if (hookTypesDev === null) {
12947
+ hookTypesDev = [hookName];
12948
+ } else {
12949
+ hookTypesDev.push(hookName);
12950
+ }
12951
+ }
12952
+ }
12953
+
12954
+ function updateHookTypesDev() {
12955
+ {
12956
+ var hookName = currentHookNameInDev;
12957
+
12958
+ if (hookTypesDev !== null) {
12959
+ hookTypesUpdateIndexDev++;
12960
+ if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
12961
+ warnOnHookMismatchInDev(hookName);
12962
+ }
12963
+ }
12964
+ }
12965
+ }
12966
+
12967
+ function warnOnHookMismatchInDev(currentHookName) {
12889
12968
  {
12890
12969
  var componentName = getComponentName(currentlyRenderingFiber$1.type);
12891
12970
  if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
12892
12971
  didWarnAboutMismatchedHooksForComponent.add(componentName);
12893
12972
 
12894
- var secondColumnStart = 22;
12973
+ if (hookTypesDev !== null) {
12974
+ var table = '';
12895
12975
 
12896
- var table = '';
12897
- var prevHook = firstCurrentHook;
12898
- var nextHook = firstWorkInProgressHook;
12899
- var n = 1;
12900
- while (prevHook !== null && nextHook !== null) {
12901
- var oldHookName = prevHook._debugType;
12902
- var newHookName = nextHook._debugType;
12976
+ var secondColumnStart = 30;
12903
12977
 
12904
- var row = n + '. ' + oldHookName;
12978
+ for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
12979
+ var oldHookName = hookTypesDev[i];
12980
+ var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
12905
12981
 
12906
- // Extra space so second column lines up
12907
- // lol @ IE not supporting String#repeat
12908
- while (row.length < secondColumnStart) {
12909
- row += ' ';
12910
- }
12982
+ var row = i + 1 + '. ' + oldHookName;
12911
12983
 
12912
- row += newHookName + '\n';
12984
+ // Extra space so second column lines up
12985
+ // lol @ IE not supporting String#repeat
12986
+ while (row.length < secondColumnStart) {
12987
+ row += ' ';
12988
+ }
12913
12989
 
12914
- table += row;
12915
- prevHook = prevHook.next;
12916
- nextHook = nextHook.next;
12917
- n++;
12918
- }
12990
+ row += newHookName + '\n';
12919
12991
 
12920
- 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);
12992
+ table += row;
12993
+ }
12994
+
12995
+ 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
+ }
12921
12997
  }
12922
12998
  }
12923
12999
  }
12924
13000
 
12925
13001
  function throwInvalidHookError() {
12926
- invariant(false, 'Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)');
13002
+ 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.');
12927
13003
  }
12928
13004
 
12929
13005
  function areHookInputsEqual(nextDeps, prevDeps) {
@@ -12953,7 +13029,12 @@ function areHookInputsEqual(nextDeps, prevDeps) {
12953
13029
  function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
12954
13030
  renderExpirationTime = nextRenderExpirationTime;
12955
13031
  currentlyRenderingFiber$1 = workInProgress;
12956
- firstCurrentHook = nextCurrentHook = current !== null ? current.memoizedState : null;
13032
+ nextCurrentHook = current !== null ? current.memoizedState : null;
13033
+
13034
+ {
13035
+ hookTypesDev = current !== null ? current._debugHookTypes : null;
13036
+ hookTypesUpdateIndexDev = -1;
13037
+ }
12957
13038
 
12958
13039
  // The following should have already been reset
12959
13040
  // currentHook = null;
@@ -12967,8 +13048,26 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12967
13048
  // numberOfReRenders = 0;
12968
13049
  // sideEffectTag = 0;
12969
13050
 
13051
+ // TODO Warn if no hooks are used at all during mount, then some are used during update.
13052
+ // Currently we will identify the update render as a mount because nextCurrentHook === null.
13053
+ // This is tricky because it's valid for certain types of components (e.g. React.lazy)
13054
+
13055
+ // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used.
13056
+ // Non-stateful hooks (e.g. context) don't get added to memoizedState,
13057
+ // so nextCurrentHook would be null during updates and mounts.
12970
13058
  {
12971
- ReactCurrentDispatcher$1.current = nextCurrentHook === null ? HooksDispatcherOnMountInDEV : HooksDispatcherOnUpdateInDEV;
13059
+ if (nextCurrentHook !== null) {
13060
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
13061
+ } else if (hookTypesDev !== null) {
13062
+ // This dispatcher handles an edge case where a component is updating,
13063
+ // but no stateful hooks have been used.
13064
+ // We want to match the production code behavior (which will use HooksDispatcherOnMount),
13065
+ // but with the extra DEV validation to ensure hooks ordering hasn't changed.
13066
+ // This dispatcher does that.
13067
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
13068
+ } else {
13069
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
13070
+ }
12972
13071
  }
12973
13072
 
12974
13073
  var children = Component(props, refOrContext);
@@ -12979,13 +13078,18 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12979
13078
  numberOfReRenders += 1;
12980
13079
 
12981
13080
  // Start over from the beginning of the list
12982
- firstCurrentHook = nextCurrentHook = current !== null ? current.memoizedState : null;
13081
+ nextCurrentHook = current !== null ? current.memoizedState : null;
12983
13082
  nextWorkInProgressHook = firstWorkInProgressHook;
12984
13083
 
12985
13084
  currentHook = null;
12986
13085
  workInProgressHook = null;
12987
13086
  componentUpdateQueue = null;
12988
13087
 
13088
+ {
13089
+ // Also validate hook order for cascading updates.
13090
+ hookTypesUpdateIndexDev = -1;
13091
+ }
13092
+
12989
13093
  ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
12990
13094
 
12991
13095
  children = Component(props, refOrContext);
@@ -12995,10 +13099,6 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12995
13099
  numberOfReRenders = 0;
12996
13100
  }
12997
13101
 
12998
- {
12999
- currentHookNameInDev = null;
13000
- }
13001
-
13002
13102
  // We can assume the previous dispatcher is always this one, since we set it
13003
13103
  // at the beginning of the render phase and there's no re-entrancy.
13004
13104
  ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
@@ -13010,18 +13110,29 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
13010
13110
  renderedWork.updateQueue = componentUpdateQueue;
13011
13111
  renderedWork.effectTag |= sideEffectTag;
13012
13112
 
13113
+ {
13114
+ renderedWork._debugHookTypes = hookTypesDev;
13115
+ }
13116
+
13117
+ // This check uses currentHook so that it works the same in DEV and prod bundles.
13118
+ // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
13013
13119
  var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
13014
13120
 
13015
13121
  renderExpirationTime = NoWork;
13016
13122
  currentlyRenderingFiber$1 = null;
13017
13123
 
13018
- firstCurrentHook = null;
13019
13124
  currentHook = null;
13020
13125
  nextCurrentHook = null;
13021
13126
  firstWorkInProgressHook = null;
13022
13127
  workInProgressHook = null;
13023
13128
  nextWorkInProgressHook = null;
13024
13129
 
13130
+ {
13131
+ currentHookNameInDev = null;
13132
+ hookTypesDev = null;
13133
+ hookTypesUpdateIndexDev = -1;
13134
+ }
13135
+
13025
13136
  remainingExpirationTime = NoWork;
13026
13137
  componentUpdateQueue = null;
13027
13138
  sideEffectTag = 0;
@@ -13055,21 +13166,23 @@ function resetHooks() {
13055
13166
  renderExpirationTime = NoWork;
13056
13167
  currentlyRenderingFiber$1 = null;
13057
13168
 
13058
- firstCurrentHook = null;
13059
13169
  currentHook = null;
13060
13170
  nextCurrentHook = null;
13061
13171
  firstWorkInProgressHook = null;
13062
13172
  workInProgressHook = null;
13063
13173
  nextWorkInProgressHook = null;
13064
13174
 
13065
- remainingExpirationTime = NoWork;
13066
- componentUpdateQueue = null;
13067
- sideEffectTag = 0;
13068
-
13069
13175
  {
13176
+ hookTypesDev = null;
13177
+ hookTypesUpdateIndexDev = -1;
13178
+
13070
13179
  currentHookNameInDev = null;
13071
13180
  }
13072
13181
 
13182
+ remainingExpirationTime = NoWork;
13183
+ componentUpdateQueue = null;
13184
+ sideEffectTag = 0;
13185
+
13073
13186
  didScheduleRenderPhaseUpdate = false;
13074
13187
  renderPhaseUpdates = null;
13075
13188
  numberOfReRenders = 0;
@@ -13086,9 +13199,6 @@ function mountWorkInProgressHook() {
13086
13199
  next: null
13087
13200
  };
13088
13201
 
13089
- {
13090
- hook._debugType = currentHookNameInDev;
13091
- }
13092
13202
  if (workInProgressHook === null) {
13093
13203
  // This is the first hook in the list
13094
13204
  firstWorkInProgressHook = workInProgressHook = hook;
@@ -13135,13 +13245,6 @@ function updateWorkInProgressHook() {
13135
13245
  workInProgressHook = workInProgressHook.next = newHook;
13136
13246
  }
13137
13247
  nextCurrentHook = currentHook.next;
13138
-
13139
- {
13140
- newHook._debugType = currentHookNameInDev;
13141
- if (currentHookNameInDev !== currentHook._debugType) {
13142
- warnOnHookMismatchInDev();
13143
- }
13144
- }
13145
13248
  }
13146
13249
  return workInProgressHook;
13147
13250
  }
@@ -13156,20 +13259,6 @@ function basicStateReducer(state, action) {
13156
13259
  return typeof action === 'function' ? action(state) : action;
13157
13260
  }
13158
13261
 
13159
- function mountContext(context, observedBits) {
13160
- {
13161
- mountWorkInProgressHook();
13162
- }
13163
- return readContext(context, observedBits);
13164
- }
13165
-
13166
- function updateContext(context, observedBits) {
13167
- {
13168
- updateWorkInProgressHook();
13169
- }
13170
- return readContext(context, observedBits);
13171
- }
13172
-
13173
13262
  function mountReducer(reducer, initialArg, init) {
13174
13263
  var hook = mountWorkInProgressHook();
13175
13264
  var initialState = void 0;
@@ -13182,8 +13271,8 @@ function mountReducer(reducer, initialArg, init) {
13182
13271
  var queue = hook.queue = {
13183
13272
  last: null,
13184
13273
  dispatch: null,
13185
- eagerReducer: reducer,
13186
- eagerState: initialState
13274
+ lastRenderedReducer: reducer,
13275
+ lastRenderedState: initialState
13187
13276
  };
13188
13277
  var dispatch = queue.dispatch = dispatchAction.bind(null,
13189
13278
  // Flow doesn't know this is non-null, but we do.
@@ -13196,6 +13285,8 @@ function updateReducer(reducer, initialArg, init) {
13196
13285
  var queue = hook.queue;
13197
13286
  !(queue !== null) ? invariant(false, 'Should have a queue. This is likely a bug in React. Please file an issue.') : void 0;
13198
13287
 
13288
+ queue.lastRenderedReducer = reducer;
13289
+
13199
13290
  if (numberOfReRenders > 0) {
13200
13291
  // This is a re-render. Apply the new render phase updates to the previous
13201
13292
  var _dispatch = queue.dispatch;
@@ -13222,7 +13313,6 @@ function updateReducer(reducer, initialArg, init) {
13222
13313
  }
13223
13314
 
13224
13315
  hook.memoizedState = newState;
13225
-
13226
13316
  // Don't persist the state accumlated from the render phase updates to
13227
13317
  // the base state unless the queue is empty.
13228
13318
  // TODO: Not sure if this is the desired semantics, but it's what we
@@ -13231,6 +13321,8 @@ function updateReducer(reducer, initialArg, init) {
13231
13321
  hook.baseState = newState;
13232
13322
  }
13233
13323
 
13324
+ queue.lastRenderedState = newState;
13325
+
13234
13326
  return [newState, _dispatch];
13235
13327
  }
13236
13328
  }
@@ -13308,8 +13400,7 @@ function updateReducer(reducer, initialArg, init) {
13308
13400
  hook.baseUpdate = newBaseUpdate;
13309
13401
  hook.baseState = newBaseState;
13310
13402
 
13311
- queue.eagerReducer = reducer;
13312
- queue.eagerState = _newState;
13403
+ queue.lastRenderedState = _newState;
13313
13404
  }
13314
13405
 
13315
13406
  var dispatch = queue.dispatch;
@@ -13325,8 +13416,8 @@ function mountState(initialState) {
13325
13416
  var queue = hook.queue = {
13326
13417
  last: null,
13327
13418
  dispatch: null,
13328
- eagerReducer: basicStateReducer,
13329
- eagerState: initialState
13419
+ lastRenderedReducer: basicStateReducer,
13420
+ lastRenderedState: initialState
13330
13421
  };
13331
13422
  var dispatch = queue.dispatch = dispatchAction.bind(null,
13332
13423
  // Flow doesn't know this is non-null, but we do.
@@ -13603,21 +13694,21 @@ function dispatchAction(fiber, queue, action) {
13603
13694
  // The queue is currently empty, which means we can eagerly compute the
13604
13695
  // next state before entering the render phase. If the new state is the
13605
13696
  // same as the current state, we may be able to bail out entirely.
13606
- var _eagerReducer = queue.eagerReducer;
13607
- if (_eagerReducer !== null) {
13697
+ var _lastRenderedReducer = queue.lastRenderedReducer;
13698
+ if (_lastRenderedReducer !== null) {
13608
13699
  var prevDispatcher = void 0;
13609
13700
  {
13610
13701
  prevDispatcher = ReactCurrentDispatcher$1.current;
13611
13702
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13612
13703
  }
13613
13704
  try {
13614
- var currentState = queue.eagerState;
13615
- var _eagerState = _eagerReducer(currentState, action);
13705
+ var currentState = queue.lastRenderedState;
13706
+ var _eagerState = _lastRenderedReducer(currentState, action);
13616
13707
  // Stash the eagerly computed state, and the reducer used to compute
13617
13708
  // it, on the update object. If the reducer hasn't changed by the
13618
13709
  // time we enter the render phase, then the eager state can be used
13619
13710
  // without calling the reducer again.
13620
- _update2.eagerReducer = _eagerReducer;
13711
+ _update2.eagerReducer = _lastRenderedReducer;
13621
13712
  _update2.eagerState = _eagerState;
13622
13713
  if (is(_eagerState, currentState)) {
13623
13714
  // Fast path. We can bail out without scheduling React to re-render.
@@ -13660,6 +13751,7 @@ var ContextOnlyDispatcher = {
13660
13751
  };
13661
13752
 
13662
13753
  var HooksDispatcherOnMountInDEV = null;
13754
+ var HooksDispatcherOnMountWithHookTypesInDEV = null;
13663
13755
  var HooksDispatcherOnUpdateInDEV = null;
13664
13756
  var InvalidNestedHooksDispatcherOnMountInDEV = null;
13665
13757
  var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
@@ -13679,26 +13771,106 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13679
13771
  },
13680
13772
  useCallback: function (callback, deps) {
13681
13773
  currentHookNameInDev = 'useCallback';
13774
+ mountHookTypesDev();
13775
+ return mountCallback(callback, deps);
13776
+ },
13777
+ useContext: function (context, observedBits) {
13778
+ currentHookNameInDev = 'useContext';
13779
+ mountHookTypesDev();
13780
+ return readContext(context, observedBits);
13781
+ },
13782
+ useEffect: function (create, deps) {
13783
+ currentHookNameInDev = 'useEffect';
13784
+ mountHookTypesDev();
13785
+ return mountEffect(create, deps);
13786
+ },
13787
+ useImperativeHandle: function (ref, create, deps) {
13788
+ currentHookNameInDev = 'useImperativeHandle';
13789
+ mountHookTypesDev();
13790
+ return mountImperativeHandle(ref, create, deps);
13791
+ },
13792
+ useLayoutEffect: function (create, deps) {
13793
+ currentHookNameInDev = 'useLayoutEffect';
13794
+ mountHookTypesDev();
13795
+ return mountLayoutEffect(create, deps);
13796
+ },
13797
+ useMemo: function (create, deps) {
13798
+ currentHookNameInDev = 'useMemo';
13799
+ mountHookTypesDev();
13800
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
13801
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13802
+ try {
13803
+ return mountMemo(create, deps);
13804
+ } finally {
13805
+ ReactCurrentDispatcher$1.current = prevDispatcher;
13806
+ }
13807
+ },
13808
+ useReducer: function (reducer, initialArg, init) {
13809
+ currentHookNameInDev = 'useReducer';
13810
+ mountHookTypesDev();
13811
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
13812
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13813
+ try {
13814
+ return mountReducer(reducer, initialArg, init);
13815
+ } finally {
13816
+ ReactCurrentDispatcher$1.current = prevDispatcher;
13817
+ }
13818
+ },
13819
+ useRef: function (initialValue) {
13820
+ currentHookNameInDev = 'useRef';
13821
+ mountHookTypesDev();
13822
+ return mountRef(initialValue);
13823
+ },
13824
+ useState: function (initialState) {
13825
+ currentHookNameInDev = 'useState';
13826
+ mountHookTypesDev();
13827
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
13828
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13829
+ try {
13830
+ return mountState(initialState);
13831
+ } finally {
13832
+ ReactCurrentDispatcher$1.current = prevDispatcher;
13833
+ }
13834
+ },
13835
+ useDebugValue: function (value, formatterFn) {
13836
+ currentHookNameInDev = 'useDebugValue';
13837
+ mountHookTypesDev();
13838
+ return mountDebugValue(value, formatterFn);
13839
+ }
13840
+ };
13841
+
13842
+ HooksDispatcherOnMountWithHookTypesInDEV = {
13843
+ readContext: function (context, observedBits) {
13844
+ return readContext(context, observedBits);
13845
+ },
13846
+ useCallback: function (callback, deps) {
13847
+ currentHookNameInDev = 'useCallback';
13848
+ updateHookTypesDev();
13682
13849
  return mountCallback(callback, deps);
13683
13850
  },
13684
13851
  useContext: function (context, observedBits) {
13685
13852
  currentHookNameInDev = 'useContext';
13686
- return mountContext(context, observedBits);
13853
+ updateHookTypesDev();
13854
+ return readContext(context, observedBits);
13687
13855
  },
13688
13856
  useEffect: function (create, deps) {
13689
13857
  currentHookNameInDev = 'useEffect';
13858
+ updateHookTypesDev();
13690
13859
  return mountEffect(create, deps);
13691
13860
  },
13692
13861
  useImperativeHandle: function (ref, create, deps) {
13693
13862
  currentHookNameInDev = 'useImperativeHandle';
13863
+ updateHookTypesDev();
13694
13864
  return mountImperativeHandle(ref, create, deps);
13695
13865
  },
13696
13866
  useLayoutEffect: function (create, deps) {
13697
13867
  currentHookNameInDev = 'useLayoutEffect';
13868
+ updateHookTypesDev();
13698
13869
  return mountLayoutEffect(create, deps);
13699
13870
  },
13700
13871
  useMemo: function (create, deps) {
13701
13872
  currentHookNameInDev = 'useMemo';
13873
+ updateHookTypesDev();
13702
13874
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13703
13875
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13704
13876
  try {
@@ -13709,6 +13881,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13709
13881
  },
13710
13882
  useReducer: function (reducer, initialArg, init) {
13711
13883
  currentHookNameInDev = 'useReducer';
13884
+ updateHookTypesDev();
13712
13885
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13713
13886
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13714
13887
  try {
@@ -13719,10 +13892,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13719
13892
  },
13720
13893
  useRef: function (initialValue) {
13721
13894
  currentHookNameInDev = 'useRef';
13895
+ updateHookTypesDev();
13722
13896
  return mountRef(initialValue);
13723
13897
  },
13724
13898
  useState: function (initialState) {
13725
13899
  currentHookNameInDev = 'useState';
13900
+ updateHookTypesDev();
13726
13901
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13727
13902
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13728
13903
  try {
@@ -13733,6 +13908,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13733
13908
  },
13734
13909
  useDebugValue: function (value, formatterFn) {
13735
13910
  currentHookNameInDev = 'useDebugValue';
13911
+ updateHookTypesDev();
13736
13912
  return mountDebugValue(value, formatterFn);
13737
13913
  }
13738
13914
  };
@@ -13743,26 +13919,32 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13743
13919
  },
13744
13920
  useCallback: function (callback, deps) {
13745
13921
  currentHookNameInDev = 'useCallback';
13922
+ updateHookTypesDev();
13746
13923
  return updateCallback(callback, deps);
13747
13924
  },
13748
13925
  useContext: function (context, observedBits) {
13749
13926
  currentHookNameInDev = 'useContext';
13750
- return updateContext(context, observedBits);
13927
+ updateHookTypesDev();
13928
+ return readContext(context, observedBits);
13751
13929
  },
13752
13930
  useEffect: function (create, deps) {
13753
13931
  currentHookNameInDev = 'useEffect';
13932
+ updateHookTypesDev();
13754
13933
  return updateEffect(create, deps);
13755
13934
  },
13756
13935
  useImperativeHandle: function (ref, create, deps) {
13757
13936
  currentHookNameInDev = 'useImperativeHandle';
13937
+ updateHookTypesDev();
13758
13938
  return updateImperativeHandle(ref, create, deps);
13759
13939
  },
13760
13940
  useLayoutEffect: function (create, deps) {
13761
13941
  currentHookNameInDev = 'useLayoutEffect';
13942
+ updateHookTypesDev();
13762
13943
  return updateLayoutEffect(create, deps);
13763
13944
  },
13764
13945
  useMemo: function (create, deps) {
13765
13946
  currentHookNameInDev = 'useMemo';
13947
+ updateHookTypesDev();
13766
13948
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13767
13949
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13768
13950
  try {
@@ -13773,6 +13955,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13773
13955
  },
13774
13956
  useReducer: function (reducer, initialArg, init) {
13775
13957
  currentHookNameInDev = 'useReducer';
13958
+ updateHookTypesDev();
13776
13959
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13777
13960
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13778
13961
  try {
@@ -13783,10 +13966,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13783
13966
  },
13784
13967
  useRef: function (initialValue) {
13785
13968
  currentHookNameInDev = 'useRef';
13969
+ updateHookTypesDev();
13786
13970
  return updateRef(initialValue);
13787
13971
  },
13788
13972
  useState: function (initialState) {
13789
13973
  currentHookNameInDev = 'useState';
13974
+ updateHookTypesDev();
13790
13975
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13791
13976
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13792
13977
  try {
@@ -13797,6 +13982,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13797
13982
  },
13798
13983
  useDebugValue: function (value, formatterFn) {
13799
13984
  currentHookNameInDev = 'useDebugValue';
13985
+ updateHookTypesDev();
13800
13986
  return updateDebugValue(value, formatterFn);
13801
13987
  }
13802
13988
  };
@@ -13809,31 +13995,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13809
13995
  useCallback: function (callback, deps) {
13810
13996
  currentHookNameInDev = 'useCallback';
13811
13997
  warnInvalidHookAccess();
13998
+ mountHookTypesDev();
13812
13999
  return mountCallback(callback, deps);
13813
14000
  },
13814
14001
  useContext: function (context, observedBits) {
13815
14002
  currentHookNameInDev = 'useContext';
13816
14003
  warnInvalidHookAccess();
13817
- return mountContext(context, observedBits);
14004
+ mountHookTypesDev();
14005
+ return readContext(context, observedBits);
13818
14006
  },
13819
14007
  useEffect: function (create, deps) {
13820
14008
  currentHookNameInDev = 'useEffect';
13821
14009
  warnInvalidHookAccess();
14010
+ mountHookTypesDev();
13822
14011
  return mountEffect(create, deps);
13823
14012
  },
13824
14013
  useImperativeHandle: function (ref, create, deps) {
13825
14014
  currentHookNameInDev = 'useImperativeHandle';
13826
14015
  warnInvalidHookAccess();
14016
+ mountHookTypesDev();
13827
14017
  return mountImperativeHandle(ref, create, deps);
13828
14018
  },
13829
14019
  useLayoutEffect: function (create, deps) {
13830
14020
  currentHookNameInDev = 'useLayoutEffect';
13831
14021
  warnInvalidHookAccess();
14022
+ mountHookTypesDev();
13832
14023
  return mountLayoutEffect(create, deps);
13833
14024
  },
13834
14025
  useMemo: function (create, deps) {
13835
14026
  currentHookNameInDev = 'useMemo';
13836
14027
  warnInvalidHookAccess();
14028
+ mountHookTypesDev();
13837
14029
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13838
14030
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13839
14031
  try {
@@ -13845,6 +14037,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13845
14037
  useReducer: function (reducer, initialArg, init) {
13846
14038
  currentHookNameInDev = 'useReducer';
13847
14039
  warnInvalidHookAccess();
14040
+ mountHookTypesDev();
13848
14041
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13849
14042
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13850
14043
  try {
@@ -13856,11 +14049,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13856
14049
  useRef: function (initialValue) {
13857
14050
  currentHookNameInDev = 'useRef';
13858
14051
  warnInvalidHookAccess();
14052
+ mountHookTypesDev();
13859
14053
  return mountRef(initialValue);
13860
14054
  },
13861
14055
  useState: function (initialState) {
13862
14056
  currentHookNameInDev = 'useState';
13863
14057
  warnInvalidHookAccess();
14058
+ mountHookTypesDev();
13864
14059
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13865
14060
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13866
14061
  try {
@@ -13872,6 +14067,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13872
14067
  useDebugValue: function (value, formatterFn) {
13873
14068
  currentHookNameInDev = 'useDebugValue';
13874
14069
  warnInvalidHookAccess();
14070
+ mountHookTypesDev();
13875
14071
  return mountDebugValue(value, formatterFn);
13876
14072
  }
13877
14073
  };
@@ -13884,31 +14080,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13884
14080
  useCallback: function (callback, deps) {
13885
14081
  currentHookNameInDev = 'useCallback';
13886
14082
  warnInvalidHookAccess();
14083
+ updateHookTypesDev();
13887
14084
  return updateCallback(callback, deps);
13888
14085
  },
13889
14086
  useContext: function (context, observedBits) {
13890
14087
  currentHookNameInDev = 'useContext';
13891
14088
  warnInvalidHookAccess();
13892
- return updateContext(context, observedBits);
14089
+ updateHookTypesDev();
14090
+ return readContext(context, observedBits);
13893
14091
  },
13894
14092
  useEffect: function (create, deps) {
13895
14093
  currentHookNameInDev = 'useEffect';
13896
14094
  warnInvalidHookAccess();
14095
+ updateHookTypesDev();
13897
14096
  return updateEffect(create, deps);
13898
14097
  },
13899
14098
  useImperativeHandle: function (ref, create, deps) {
13900
14099
  currentHookNameInDev = 'useImperativeHandle';
13901
14100
  warnInvalidHookAccess();
14101
+ updateHookTypesDev();
13902
14102
  return updateImperativeHandle(ref, create, deps);
13903
14103
  },
13904
14104
  useLayoutEffect: function (create, deps) {
13905
14105
  currentHookNameInDev = 'useLayoutEffect';
13906
14106
  warnInvalidHookAccess();
14107
+ updateHookTypesDev();
13907
14108
  return updateLayoutEffect(create, deps);
13908
14109
  },
13909
14110
  useMemo: function (create, deps) {
13910
14111
  currentHookNameInDev = 'useMemo';
13911
14112
  warnInvalidHookAccess();
14113
+ updateHookTypesDev();
13912
14114
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13913
14115
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13914
14116
  try {
@@ -13920,6 +14122,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13920
14122
  useReducer: function (reducer, initialArg, init) {
13921
14123
  currentHookNameInDev = 'useReducer';
13922
14124
  warnInvalidHookAccess();
14125
+ updateHookTypesDev();
13923
14126
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13924
14127
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13925
14128
  try {
@@ -13931,11 +14134,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13931
14134
  useRef: function (initialValue) {
13932
14135
  currentHookNameInDev = 'useRef';
13933
14136
  warnInvalidHookAccess();
14137
+ updateHookTypesDev();
13934
14138
  return updateRef(initialValue);
13935
14139
  },
13936
14140
  useState: function (initialState) {
13937
14141
  currentHookNameInDev = 'useState';
13938
14142
  warnInvalidHookAccess();
14143
+ updateHookTypesDev();
13939
14144
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13940
14145
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13941
14146
  try {
@@ -13947,6 +14152,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13947
14152
  useDebugValue: function (value, formatterFn) {
13948
14153
  currentHookNameInDev = 'useDebugValue';
13949
14154
  warnInvalidHookAccess();
14155
+ updateHookTypesDev();
13950
14156
  return updateDebugValue(value, formatterFn);
13951
14157
  }
13952
14158
  };
@@ -17218,11 +17424,11 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) {
17218
17424
  if (_destroy === null) {
17219
17425
  addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
17220
17426
  } else if (typeof _destroy.then === 'function') {
17221
- 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.";
17427
+ 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';
17222
17428
  } else {
17223
17429
  addendum = ' You returned: ' + _destroy;
17224
17430
  }
17225
- warningWithoutStack$1(false, 'An Effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
17431
+ warningWithoutStack$1(false, 'An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
17226
17432
  }
17227
17433
  }
17228
17434
  }
@@ -20681,7 +20887,7 @@ implementation) {
20681
20887
 
20682
20888
  // TODO: this is special because it gets imported during build.
20683
20889
 
20684
- var ReactVersion = '16.8.2';
20890
+ var ReactVersion = '16.8.6';
20685
20891
 
20686
20892
  // TODO: This type is shared between the reconciler and ReactDOM, but will
20687
20893
  // eventually be lifted out to the renderer.