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.
@@ -5332,15 +5332,29 @@ function isInDocument(node) {
5332
5332
  return node && node.ownerDocument && containsNode(node.ownerDocument.documentElement, node);
5333
5333
  }
5334
5334
 
5335
+ function isSameOriginFrame(iframe) {
5336
+ try {
5337
+ // Accessing the contentDocument of a HTMLIframeElement can cause the browser
5338
+ // to throw, e.g. if it has a cross-origin src attribute.
5339
+ // Safari will show an error in the console when the access results in "Blocked a frame with origin". e.g:
5340
+ // iframe.contentDocument.defaultView;
5341
+ // A safety way is to access one of the cross origin properties: Window or Location
5342
+ // Which might result in "SecurityError" DOM Exception and it is compatible to Safari.
5343
+ // https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl
5344
+
5345
+ return typeof iframe.contentWindow.location.href === 'string';
5346
+ } catch (err) {
5347
+ return false;
5348
+ }
5349
+ }
5350
+
5335
5351
  function getActiveElementDeep() {
5336
5352
  var win = window;
5337
5353
  var element = getActiveElement();
5338
5354
  while (element instanceof win.HTMLIFrameElement) {
5339
- // Accessing the contentDocument of a HTMLIframeElement can cause the browser
5340
- // to throw, e.g. if it has a cross-origin src attribute
5341
- try {
5342
- win = element.contentDocument.defaultView;
5343
- } catch (e) {
5355
+ if (isSameOriginFrame(element)) {
5356
+ win = element.contentWindow;
5357
+ } else {
5344
5358
  return element;
5345
5359
  }
5346
5360
  element = getActiveElement(win.document);
@@ -7630,14 +7644,25 @@ function createElement(type, props, rootContainerElement, parentNamespace) {
7630
7644
  // See discussion in https://github.com/facebook/react/pull/6896
7631
7645
  // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
7632
7646
  domElement = ownerDocument.createElement(type);
7633
- // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple`
7634
- // attribute on `select`s needs to be added before `option`s are inserted. This prevents
7635
- // a bug where the `select` does not scroll to the correct option because singular
7636
- // `select` elements automatically pick the first item.
7647
+ // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple` and `size`
7648
+ // attributes on `select`s needs to be added before `option`s are inserted.
7649
+ // This prevents:
7650
+ // - a bug where the `select` does not scroll to the correct option because singular
7651
+ // `select` elements automatically pick the first item #13222
7652
+ // - a bug where the `select` set the first item as selected despite the `size` attribute #14239
7637
7653
  // See https://github.com/facebook/react/issues/13222
7638
- if (type === 'select' && props.multiple) {
7654
+ // and https://github.com/facebook/react/issues/14239
7655
+ if (type === 'select') {
7639
7656
  var node = domElement;
7640
- node.multiple = true;
7657
+ if (props.multiple) {
7658
+ node.multiple = true;
7659
+ } else if (props.size) {
7660
+ // Setting a size greater than 1 causes a select to behave like `multiple=true`, where
7661
+ // it is possible that no option is selected.
7662
+ //
7663
+ // This is only necessary when a select in "single selection mode".
7664
+ node.size = props.size;
7665
+ }
7641
7666
  }
7642
7667
  }
7643
7668
  } else {
@@ -10001,6 +10026,7 @@ function FiberNode(tag, pendingProps, key, mode) {
10001
10026
  this._debugSource = null;
10002
10027
  this._debugOwner = null;
10003
10028
  this._debugIsCurrentlyTiming = false;
10029
+ this._debugHookTypes = null;
10004
10030
  if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
10005
10031
  Object.preventExtensions(this);
10006
10032
  }
@@ -10068,6 +10094,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
10068
10094
  workInProgress._debugID = current._debugID;
10069
10095
  workInProgress._debugSource = current._debugSource;
10070
10096
  workInProgress._debugOwner = current._debugOwner;
10097
+ workInProgress._debugHookTypes = current._debugHookTypes;
10071
10098
  }
10072
10099
 
10073
10100
  workInProgress.alternate = current;
@@ -10335,6 +10362,7 @@ function assignFiberPropertiesInDEV(target, source) {
10335
10362
  target._debugSource = source._debugSource;
10336
10363
  target._debugOwner = source._debugOwner;
10337
10364
  target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
10365
+ target._debugHookTypes = source._debugHookTypes;
10338
10366
  return target;
10339
10367
  }
10340
10368
 
@@ -11286,14 +11314,35 @@ function constructClassInstance(workInProgress, ctor, props, renderExpirationTim
11286
11314
  var unmaskedContext = emptyContextObject;
11287
11315
  var context = null;
11288
11316
  var contextType = ctor.contextType;
11289
- if (typeof contextType === 'object' && contextType !== null) {
11290
- {
11291
- if (contextType.$$typeof !== REACT_CONTEXT_TYPE && !didWarnAboutInvalidateContextType.has(ctor)) {
11317
+
11318
+ {
11319
+ if ('contextType' in ctor) {
11320
+ var isValid =
11321
+ // Allow null for conditional declaration
11322
+ contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer>
11323
+
11324
+ if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
11292
11325
  didWarnAboutInvalidateContextType.add(ctor);
11293
- 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');
11326
+
11327
+ var addendum = '';
11328
+ if (contextType === undefined) {
11329
+ 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.';
11330
+ } else if (typeof contextType !== 'object') {
11331
+ addendum = ' However, it is set to a ' + typeof contextType + '.';
11332
+ } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
11333
+ addendum = ' Did you accidentally pass the Context.Provider instead?';
11334
+ } else if (contextType._context !== undefined) {
11335
+ // <Context.Consumer>
11336
+ addendum = ' Did you accidentally pass the Context.Consumer instead?';
11337
+ } else {
11338
+ addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
11339
+ }
11340
+ warningWithoutStack$1(false, '%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum);
11294
11341
  }
11295
11342
  }
11343
+ }
11296
11344
 
11345
+ if (typeof contextType === 'object' && contextType !== null) {
11297
11346
  context = readContext(contextType);
11298
11347
  } else {
11299
11348
  unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
@@ -12720,7 +12769,6 @@ var currentlyRenderingFiber$1 = null;
12720
12769
  // current hook list is the list that belongs to the current fiber. The
12721
12770
  // work-in-progress hook list is a new list that will be added to the
12722
12771
  // work-in-progress fiber.
12723
- var firstCurrentHook = null;
12724
12772
  var currentHook = null;
12725
12773
  var nextCurrentHook = null;
12726
12774
  var firstWorkInProgressHook = null;
@@ -12750,45 +12798,73 @@ var RE_RENDER_LIMIT = 25;
12750
12798
  // In DEV, this is the name of the currently executing primitive hook
12751
12799
  var currentHookNameInDev = null;
12752
12800
 
12753
- function warnOnHookMismatchInDev() {
12801
+ // In DEV, this list ensures that hooks are called in the same order between renders.
12802
+ // The list stores the order of hooks used during the initial render (mount).
12803
+ // Subsequent renders (updates) reference this list.
12804
+ var hookTypesDev = null;
12805
+ var hookTypesUpdateIndexDev = -1;
12806
+
12807
+ function mountHookTypesDev() {
12808
+ {
12809
+ var hookName = currentHookNameInDev;
12810
+
12811
+ if (hookTypesDev === null) {
12812
+ hookTypesDev = [hookName];
12813
+ } else {
12814
+ hookTypesDev.push(hookName);
12815
+ }
12816
+ }
12817
+ }
12818
+
12819
+ function updateHookTypesDev() {
12820
+ {
12821
+ var hookName = currentHookNameInDev;
12822
+
12823
+ if (hookTypesDev !== null) {
12824
+ hookTypesUpdateIndexDev++;
12825
+ if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
12826
+ warnOnHookMismatchInDev(hookName);
12827
+ }
12828
+ }
12829
+ }
12830
+ }
12831
+
12832
+ function warnOnHookMismatchInDev(currentHookName) {
12754
12833
  {
12755
12834
  var componentName = getComponentName(currentlyRenderingFiber$1.type);
12756
12835
  if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
12757
12836
  didWarnAboutMismatchedHooksForComponent.add(componentName);
12758
12837
 
12759
- var secondColumnStart = 22;
12838
+ if (hookTypesDev !== null) {
12839
+ var table = '';
12760
12840
 
12761
- var table = '';
12762
- var prevHook = firstCurrentHook;
12763
- var nextHook = firstWorkInProgressHook;
12764
- var n = 1;
12765
- while (prevHook !== null && nextHook !== null) {
12766
- var oldHookName = prevHook._debugType;
12767
- var newHookName = nextHook._debugType;
12841
+ var secondColumnStart = 30;
12768
12842
 
12769
- var row = n + '. ' + oldHookName;
12843
+ for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
12844
+ var oldHookName = hookTypesDev[i];
12845
+ var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
12770
12846
 
12771
- // Extra space so second column lines up
12772
- // lol @ IE not supporting String#repeat
12773
- while (row.length < secondColumnStart) {
12774
- row += ' ';
12775
- }
12847
+ var row = i + 1 + '. ' + oldHookName;
12776
12848
 
12777
- row += newHookName + '\n';
12849
+ // Extra space so second column lines up
12850
+ // lol @ IE not supporting String#repeat
12851
+ while (row.length < secondColumnStart) {
12852
+ row += ' ';
12853
+ }
12778
12854
 
12779
- table += row;
12780
- prevHook = prevHook.next;
12781
- nextHook = nextHook.next;
12782
- n++;
12783
- }
12855
+ row += newHookName + '\n';
12784
12856
 
12785
- 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);
12857
+ table += row;
12858
+ }
12859
+
12860
+ 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);
12861
+ }
12786
12862
  }
12787
12863
  }
12788
12864
  }
12789
12865
 
12790
12866
  function throwInvalidHookError() {
12791
- invariant(false, 'Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)');
12867
+ 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.');
12792
12868
  }
12793
12869
 
12794
12870
  function areHookInputsEqual(nextDeps, prevDeps) {
@@ -12818,7 +12894,12 @@ function areHookInputsEqual(nextDeps, prevDeps) {
12818
12894
  function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
12819
12895
  renderExpirationTime = nextRenderExpirationTime;
12820
12896
  currentlyRenderingFiber$1 = workInProgress;
12821
- firstCurrentHook = nextCurrentHook = current !== null ? current.memoizedState : null;
12897
+ nextCurrentHook = current !== null ? current.memoizedState : null;
12898
+
12899
+ {
12900
+ hookTypesDev = current !== null ? current._debugHookTypes : null;
12901
+ hookTypesUpdateIndexDev = -1;
12902
+ }
12822
12903
 
12823
12904
  // The following should have already been reset
12824
12905
  // currentHook = null;
@@ -12832,8 +12913,26 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12832
12913
  // numberOfReRenders = 0;
12833
12914
  // sideEffectTag = 0;
12834
12915
 
12916
+ // TODO Warn if no hooks are used at all during mount, then some are used during update.
12917
+ // Currently we will identify the update render as a mount because nextCurrentHook === null.
12918
+ // This is tricky because it's valid for certain types of components (e.g. React.lazy)
12919
+
12920
+ // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used.
12921
+ // Non-stateful hooks (e.g. context) don't get added to memoizedState,
12922
+ // so nextCurrentHook would be null during updates and mounts.
12835
12923
  {
12836
- ReactCurrentDispatcher$1.current = nextCurrentHook === null ? HooksDispatcherOnMountInDEV : HooksDispatcherOnUpdateInDEV;
12924
+ if (nextCurrentHook !== null) {
12925
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
12926
+ } else if (hookTypesDev !== null) {
12927
+ // This dispatcher handles an edge case where a component is updating,
12928
+ // but no stateful hooks have been used.
12929
+ // We want to match the production code behavior (which will use HooksDispatcherOnMount),
12930
+ // but with the extra DEV validation to ensure hooks ordering hasn't changed.
12931
+ // This dispatcher does that.
12932
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
12933
+ } else {
12934
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
12935
+ }
12837
12936
  }
12838
12937
 
12839
12938
  var children = Component(props, refOrContext);
@@ -12844,13 +12943,18 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12844
12943
  numberOfReRenders += 1;
12845
12944
 
12846
12945
  // Start over from the beginning of the list
12847
- firstCurrentHook = nextCurrentHook = current !== null ? current.memoizedState : null;
12946
+ nextCurrentHook = current !== null ? current.memoizedState : null;
12848
12947
  nextWorkInProgressHook = firstWorkInProgressHook;
12849
12948
 
12850
12949
  currentHook = null;
12851
12950
  workInProgressHook = null;
12852
12951
  componentUpdateQueue = null;
12853
12952
 
12953
+ {
12954
+ // Also validate hook order for cascading updates.
12955
+ hookTypesUpdateIndexDev = -1;
12956
+ }
12957
+
12854
12958
  ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
12855
12959
 
12856
12960
  children = Component(props, refOrContext);
@@ -12860,10 +12964,6 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12860
12964
  numberOfReRenders = 0;
12861
12965
  }
12862
12966
 
12863
- {
12864
- currentHookNameInDev = null;
12865
- }
12866
-
12867
12967
  // We can assume the previous dispatcher is always this one, since we set it
12868
12968
  // at the beginning of the render phase and there's no re-entrancy.
12869
12969
  ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
@@ -12875,18 +12975,29 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
12875
12975
  renderedWork.updateQueue = componentUpdateQueue;
12876
12976
  renderedWork.effectTag |= sideEffectTag;
12877
12977
 
12978
+ {
12979
+ renderedWork._debugHookTypes = hookTypesDev;
12980
+ }
12981
+
12982
+ // This check uses currentHook so that it works the same in DEV and prod bundles.
12983
+ // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
12878
12984
  var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
12879
12985
 
12880
12986
  renderExpirationTime = NoWork;
12881
12987
  currentlyRenderingFiber$1 = null;
12882
12988
 
12883
- firstCurrentHook = null;
12884
12989
  currentHook = null;
12885
12990
  nextCurrentHook = null;
12886
12991
  firstWorkInProgressHook = null;
12887
12992
  workInProgressHook = null;
12888
12993
  nextWorkInProgressHook = null;
12889
12994
 
12995
+ {
12996
+ currentHookNameInDev = null;
12997
+ hookTypesDev = null;
12998
+ hookTypesUpdateIndexDev = -1;
12999
+ }
13000
+
12890
13001
  remainingExpirationTime = NoWork;
12891
13002
  componentUpdateQueue = null;
12892
13003
  sideEffectTag = 0;
@@ -12920,21 +13031,23 @@ function resetHooks() {
12920
13031
  renderExpirationTime = NoWork;
12921
13032
  currentlyRenderingFiber$1 = null;
12922
13033
 
12923
- firstCurrentHook = null;
12924
13034
  currentHook = null;
12925
13035
  nextCurrentHook = null;
12926
13036
  firstWorkInProgressHook = null;
12927
13037
  workInProgressHook = null;
12928
13038
  nextWorkInProgressHook = null;
12929
13039
 
12930
- remainingExpirationTime = NoWork;
12931
- componentUpdateQueue = null;
12932
- sideEffectTag = 0;
12933
-
12934
13040
  {
13041
+ hookTypesDev = null;
13042
+ hookTypesUpdateIndexDev = -1;
13043
+
12935
13044
  currentHookNameInDev = null;
12936
13045
  }
12937
13046
 
13047
+ remainingExpirationTime = NoWork;
13048
+ componentUpdateQueue = null;
13049
+ sideEffectTag = 0;
13050
+
12938
13051
  didScheduleRenderPhaseUpdate = false;
12939
13052
  renderPhaseUpdates = null;
12940
13053
  numberOfReRenders = 0;
@@ -12951,9 +13064,6 @@ function mountWorkInProgressHook() {
12951
13064
  next: null
12952
13065
  };
12953
13066
 
12954
- {
12955
- hook._debugType = currentHookNameInDev;
12956
- }
12957
13067
  if (workInProgressHook === null) {
12958
13068
  // This is the first hook in the list
12959
13069
  firstWorkInProgressHook = workInProgressHook = hook;
@@ -13000,13 +13110,6 @@ function updateWorkInProgressHook() {
13000
13110
  workInProgressHook = workInProgressHook.next = newHook;
13001
13111
  }
13002
13112
  nextCurrentHook = currentHook.next;
13003
-
13004
- {
13005
- newHook._debugType = currentHookNameInDev;
13006
- if (currentHookNameInDev !== currentHook._debugType) {
13007
- warnOnHookMismatchInDev();
13008
- }
13009
- }
13010
13113
  }
13011
13114
  return workInProgressHook;
13012
13115
  }
@@ -13021,20 +13124,6 @@ function basicStateReducer(state, action) {
13021
13124
  return typeof action === 'function' ? action(state) : action;
13022
13125
  }
13023
13126
 
13024
- function mountContext(context, observedBits) {
13025
- {
13026
- mountWorkInProgressHook();
13027
- }
13028
- return readContext(context, observedBits);
13029
- }
13030
-
13031
- function updateContext(context, observedBits) {
13032
- {
13033
- updateWorkInProgressHook();
13034
- }
13035
- return readContext(context, observedBits);
13036
- }
13037
-
13038
13127
  function mountReducer(reducer, initialArg, init) {
13039
13128
  var hook = mountWorkInProgressHook();
13040
13129
  var initialState = void 0;
@@ -13047,8 +13136,8 @@ function mountReducer(reducer, initialArg, init) {
13047
13136
  var queue = hook.queue = {
13048
13137
  last: null,
13049
13138
  dispatch: null,
13050
- eagerReducer: reducer,
13051
- eagerState: initialState
13139
+ lastRenderedReducer: reducer,
13140
+ lastRenderedState: initialState
13052
13141
  };
13053
13142
  var dispatch = queue.dispatch = dispatchAction.bind(null,
13054
13143
  // Flow doesn't know this is non-null, but we do.
@@ -13061,6 +13150,8 @@ function updateReducer(reducer, initialArg, init) {
13061
13150
  var queue = hook.queue;
13062
13151
  !(queue !== null) ? invariant(false, 'Should have a queue. This is likely a bug in React. Please file an issue.') : void 0;
13063
13152
 
13153
+ queue.lastRenderedReducer = reducer;
13154
+
13064
13155
  if (numberOfReRenders > 0) {
13065
13156
  // This is a re-render. Apply the new render phase updates to the previous
13066
13157
  var _dispatch = queue.dispatch;
@@ -13087,7 +13178,6 @@ function updateReducer(reducer, initialArg, init) {
13087
13178
  }
13088
13179
 
13089
13180
  hook.memoizedState = newState;
13090
-
13091
13181
  // Don't persist the state accumlated from the render phase updates to
13092
13182
  // the base state unless the queue is empty.
13093
13183
  // TODO: Not sure if this is the desired semantics, but it's what we
@@ -13096,6 +13186,8 @@ function updateReducer(reducer, initialArg, init) {
13096
13186
  hook.baseState = newState;
13097
13187
  }
13098
13188
 
13189
+ queue.lastRenderedState = newState;
13190
+
13099
13191
  return [newState, _dispatch];
13100
13192
  }
13101
13193
  }
@@ -13173,8 +13265,7 @@ function updateReducer(reducer, initialArg, init) {
13173
13265
  hook.baseUpdate = newBaseUpdate;
13174
13266
  hook.baseState = newBaseState;
13175
13267
 
13176
- queue.eagerReducer = reducer;
13177
- queue.eagerState = _newState;
13268
+ queue.lastRenderedState = _newState;
13178
13269
  }
13179
13270
 
13180
13271
  var dispatch = queue.dispatch;
@@ -13190,8 +13281,8 @@ function mountState(initialState) {
13190
13281
  var queue = hook.queue = {
13191
13282
  last: null,
13192
13283
  dispatch: null,
13193
- eagerReducer: basicStateReducer,
13194
- eagerState: initialState
13284
+ lastRenderedReducer: basicStateReducer,
13285
+ lastRenderedState: initialState
13195
13286
  };
13196
13287
  var dispatch = queue.dispatch = dispatchAction.bind(null,
13197
13288
  // Flow doesn't know this is non-null, but we do.
@@ -13468,21 +13559,21 @@ function dispatchAction(fiber, queue, action) {
13468
13559
  // The queue is currently empty, which means we can eagerly compute the
13469
13560
  // next state before entering the render phase. If the new state is the
13470
13561
  // same as the current state, we may be able to bail out entirely.
13471
- var _eagerReducer = queue.eagerReducer;
13472
- if (_eagerReducer !== null) {
13562
+ var _lastRenderedReducer = queue.lastRenderedReducer;
13563
+ if (_lastRenderedReducer !== null) {
13473
13564
  var prevDispatcher = void 0;
13474
13565
  {
13475
13566
  prevDispatcher = ReactCurrentDispatcher$1.current;
13476
13567
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13477
13568
  }
13478
13569
  try {
13479
- var currentState = queue.eagerState;
13480
- var _eagerState = _eagerReducer(currentState, action);
13570
+ var currentState = queue.lastRenderedState;
13571
+ var _eagerState = _lastRenderedReducer(currentState, action);
13481
13572
  // Stash the eagerly computed state, and the reducer used to compute
13482
13573
  // it, on the update object. If the reducer hasn't changed by the
13483
13574
  // time we enter the render phase, then the eager state can be used
13484
13575
  // without calling the reducer again.
13485
- _update2.eagerReducer = _eagerReducer;
13576
+ _update2.eagerReducer = _lastRenderedReducer;
13486
13577
  _update2.eagerState = _eagerState;
13487
13578
  if (is(_eagerState, currentState)) {
13488
13579
  // Fast path. We can bail out without scheduling React to re-render.
@@ -13525,6 +13616,7 @@ var ContextOnlyDispatcher = {
13525
13616
  };
13526
13617
 
13527
13618
  var HooksDispatcherOnMountInDEV = null;
13619
+ var HooksDispatcherOnMountWithHookTypesInDEV = null;
13528
13620
  var HooksDispatcherOnUpdateInDEV = null;
13529
13621
  var InvalidNestedHooksDispatcherOnMountInDEV = null;
13530
13622
  var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
@@ -13544,26 +13636,106 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13544
13636
  },
13545
13637
  useCallback: function (callback, deps) {
13546
13638
  currentHookNameInDev = 'useCallback';
13639
+ mountHookTypesDev();
13640
+ return mountCallback(callback, deps);
13641
+ },
13642
+ useContext: function (context, observedBits) {
13643
+ currentHookNameInDev = 'useContext';
13644
+ mountHookTypesDev();
13645
+ return readContext(context, observedBits);
13646
+ },
13647
+ useEffect: function (create, deps) {
13648
+ currentHookNameInDev = 'useEffect';
13649
+ mountHookTypesDev();
13650
+ return mountEffect(create, deps);
13651
+ },
13652
+ useImperativeHandle: function (ref, create, deps) {
13653
+ currentHookNameInDev = 'useImperativeHandle';
13654
+ mountHookTypesDev();
13655
+ return mountImperativeHandle(ref, create, deps);
13656
+ },
13657
+ useLayoutEffect: function (create, deps) {
13658
+ currentHookNameInDev = 'useLayoutEffect';
13659
+ mountHookTypesDev();
13660
+ return mountLayoutEffect(create, deps);
13661
+ },
13662
+ useMemo: function (create, deps) {
13663
+ currentHookNameInDev = 'useMemo';
13664
+ mountHookTypesDev();
13665
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
13666
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13667
+ try {
13668
+ return mountMemo(create, deps);
13669
+ } finally {
13670
+ ReactCurrentDispatcher$1.current = prevDispatcher;
13671
+ }
13672
+ },
13673
+ useReducer: function (reducer, initialArg, init) {
13674
+ currentHookNameInDev = 'useReducer';
13675
+ mountHookTypesDev();
13676
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
13677
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13678
+ try {
13679
+ return mountReducer(reducer, initialArg, init);
13680
+ } finally {
13681
+ ReactCurrentDispatcher$1.current = prevDispatcher;
13682
+ }
13683
+ },
13684
+ useRef: function (initialValue) {
13685
+ currentHookNameInDev = 'useRef';
13686
+ mountHookTypesDev();
13687
+ return mountRef(initialValue);
13688
+ },
13689
+ useState: function (initialState) {
13690
+ currentHookNameInDev = 'useState';
13691
+ mountHookTypesDev();
13692
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
13693
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13694
+ try {
13695
+ return mountState(initialState);
13696
+ } finally {
13697
+ ReactCurrentDispatcher$1.current = prevDispatcher;
13698
+ }
13699
+ },
13700
+ useDebugValue: function (value, formatterFn) {
13701
+ currentHookNameInDev = 'useDebugValue';
13702
+ mountHookTypesDev();
13703
+ return mountDebugValue(value, formatterFn);
13704
+ }
13705
+ };
13706
+
13707
+ HooksDispatcherOnMountWithHookTypesInDEV = {
13708
+ readContext: function (context, observedBits) {
13709
+ return readContext(context, observedBits);
13710
+ },
13711
+ useCallback: function (callback, deps) {
13712
+ currentHookNameInDev = 'useCallback';
13713
+ updateHookTypesDev();
13547
13714
  return mountCallback(callback, deps);
13548
13715
  },
13549
13716
  useContext: function (context, observedBits) {
13550
13717
  currentHookNameInDev = 'useContext';
13551
- return mountContext(context, observedBits);
13718
+ updateHookTypesDev();
13719
+ return readContext(context, observedBits);
13552
13720
  },
13553
13721
  useEffect: function (create, deps) {
13554
13722
  currentHookNameInDev = 'useEffect';
13723
+ updateHookTypesDev();
13555
13724
  return mountEffect(create, deps);
13556
13725
  },
13557
13726
  useImperativeHandle: function (ref, create, deps) {
13558
13727
  currentHookNameInDev = 'useImperativeHandle';
13728
+ updateHookTypesDev();
13559
13729
  return mountImperativeHandle(ref, create, deps);
13560
13730
  },
13561
13731
  useLayoutEffect: function (create, deps) {
13562
13732
  currentHookNameInDev = 'useLayoutEffect';
13733
+ updateHookTypesDev();
13563
13734
  return mountLayoutEffect(create, deps);
13564
13735
  },
13565
13736
  useMemo: function (create, deps) {
13566
13737
  currentHookNameInDev = 'useMemo';
13738
+ updateHookTypesDev();
13567
13739
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13568
13740
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13569
13741
  try {
@@ -13574,6 +13746,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13574
13746
  },
13575
13747
  useReducer: function (reducer, initialArg, init) {
13576
13748
  currentHookNameInDev = 'useReducer';
13749
+ updateHookTypesDev();
13577
13750
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13578
13751
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13579
13752
  try {
@@ -13584,10 +13757,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13584
13757
  },
13585
13758
  useRef: function (initialValue) {
13586
13759
  currentHookNameInDev = 'useRef';
13760
+ updateHookTypesDev();
13587
13761
  return mountRef(initialValue);
13588
13762
  },
13589
13763
  useState: function (initialState) {
13590
13764
  currentHookNameInDev = 'useState';
13765
+ updateHookTypesDev();
13591
13766
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13592
13767
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13593
13768
  try {
@@ -13598,6 +13773,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13598
13773
  },
13599
13774
  useDebugValue: function (value, formatterFn) {
13600
13775
  currentHookNameInDev = 'useDebugValue';
13776
+ updateHookTypesDev();
13601
13777
  return mountDebugValue(value, formatterFn);
13602
13778
  }
13603
13779
  };
@@ -13608,26 +13784,32 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13608
13784
  },
13609
13785
  useCallback: function (callback, deps) {
13610
13786
  currentHookNameInDev = 'useCallback';
13787
+ updateHookTypesDev();
13611
13788
  return updateCallback(callback, deps);
13612
13789
  },
13613
13790
  useContext: function (context, observedBits) {
13614
13791
  currentHookNameInDev = 'useContext';
13615
- return updateContext(context, observedBits);
13792
+ updateHookTypesDev();
13793
+ return readContext(context, observedBits);
13616
13794
  },
13617
13795
  useEffect: function (create, deps) {
13618
13796
  currentHookNameInDev = 'useEffect';
13797
+ updateHookTypesDev();
13619
13798
  return updateEffect(create, deps);
13620
13799
  },
13621
13800
  useImperativeHandle: function (ref, create, deps) {
13622
13801
  currentHookNameInDev = 'useImperativeHandle';
13802
+ updateHookTypesDev();
13623
13803
  return updateImperativeHandle(ref, create, deps);
13624
13804
  },
13625
13805
  useLayoutEffect: function (create, deps) {
13626
13806
  currentHookNameInDev = 'useLayoutEffect';
13807
+ updateHookTypesDev();
13627
13808
  return updateLayoutEffect(create, deps);
13628
13809
  },
13629
13810
  useMemo: function (create, deps) {
13630
13811
  currentHookNameInDev = 'useMemo';
13812
+ updateHookTypesDev();
13631
13813
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13632
13814
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13633
13815
  try {
@@ -13638,6 +13820,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13638
13820
  },
13639
13821
  useReducer: function (reducer, initialArg, init) {
13640
13822
  currentHookNameInDev = 'useReducer';
13823
+ updateHookTypesDev();
13641
13824
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13642
13825
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13643
13826
  try {
@@ -13648,10 +13831,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13648
13831
  },
13649
13832
  useRef: function (initialValue) {
13650
13833
  currentHookNameInDev = 'useRef';
13834
+ updateHookTypesDev();
13651
13835
  return updateRef(initialValue);
13652
13836
  },
13653
13837
  useState: function (initialState) {
13654
13838
  currentHookNameInDev = 'useState';
13839
+ updateHookTypesDev();
13655
13840
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13656
13841
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13657
13842
  try {
@@ -13662,6 +13847,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13662
13847
  },
13663
13848
  useDebugValue: function (value, formatterFn) {
13664
13849
  currentHookNameInDev = 'useDebugValue';
13850
+ updateHookTypesDev();
13665
13851
  return updateDebugValue(value, formatterFn);
13666
13852
  }
13667
13853
  };
@@ -13674,31 +13860,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13674
13860
  useCallback: function (callback, deps) {
13675
13861
  currentHookNameInDev = 'useCallback';
13676
13862
  warnInvalidHookAccess();
13863
+ mountHookTypesDev();
13677
13864
  return mountCallback(callback, deps);
13678
13865
  },
13679
13866
  useContext: function (context, observedBits) {
13680
13867
  currentHookNameInDev = 'useContext';
13681
13868
  warnInvalidHookAccess();
13682
- return mountContext(context, observedBits);
13869
+ mountHookTypesDev();
13870
+ return readContext(context, observedBits);
13683
13871
  },
13684
13872
  useEffect: function (create, deps) {
13685
13873
  currentHookNameInDev = 'useEffect';
13686
13874
  warnInvalidHookAccess();
13875
+ mountHookTypesDev();
13687
13876
  return mountEffect(create, deps);
13688
13877
  },
13689
13878
  useImperativeHandle: function (ref, create, deps) {
13690
13879
  currentHookNameInDev = 'useImperativeHandle';
13691
13880
  warnInvalidHookAccess();
13881
+ mountHookTypesDev();
13692
13882
  return mountImperativeHandle(ref, create, deps);
13693
13883
  },
13694
13884
  useLayoutEffect: function (create, deps) {
13695
13885
  currentHookNameInDev = 'useLayoutEffect';
13696
13886
  warnInvalidHookAccess();
13887
+ mountHookTypesDev();
13697
13888
  return mountLayoutEffect(create, deps);
13698
13889
  },
13699
13890
  useMemo: function (create, deps) {
13700
13891
  currentHookNameInDev = 'useMemo';
13701
13892
  warnInvalidHookAccess();
13893
+ mountHookTypesDev();
13702
13894
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13703
13895
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13704
13896
  try {
@@ -13710,6 +13902,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13710
13902
  useReducer: function (reducer, initialArg, init) {
13711
13903
  currentHookNameInDev = 'useReducer';
13712
13904
  warnInvalidHookAccess();
13905
+ mountHookTypesDev();
13713
13906
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13714
13907
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13715
13908
  try {
@@ -13721,11 +13914,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13721
13914
  useRef: function (initialValue) {
13722
13915
  currentHookNameInDev = 'useRef';
13723
13916
  warnInvalidHookAccess();
13917
+ mountHookTypesDev();
13724
13918
  return mountRef(initialValue);
13725
13919
  },
13726
13920
  useState: function (initialState) {
13727
13921
  currentHookNameInDev = 'useState';
13728
13922
  warnInvalidHookAccess();
13923
+ mountHookTypesDev();
13729
13924
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13730
13925
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
13731
13926
  try {
@@ -13737,6 +13932,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13737
13932
  useDebugValue: function (value, formatterFn) {
13738
13933
  currentHookNameInDev = 'useDebugValue';
13739
13934
  warnInvalidHookAccess();
13935
+ mountHookTypesDev();
13740
13936
  return mountDebugValue(value, formatterFn);
13741
13937
  }
13742
13938
  };
@@ -13749,31 +13945,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13749
13945
  useCallback: function (callback, deps) {
13750
13946
  currentHookNameInDev = 'useCallback';
13751
13947
  warnInvalidHookAccess();
13948
+ updateHookTypesDev();
13752
13949
  return updateCallback(callback, deps);
13753
13950
  },
13754
13951
  useContext: function (context, observedBits) {
13755
13952
  currentHookNameInDev = 'useContext';
13756
13953
  warnInvalidHookAccess();
13757
- return updateContext(context, observedBits);
13954
+ updateHookTypesDev();
13955
+ return readContext(context, observedBits);
13758
13956
  },
13759
13957
  useEffect: function (create, deps) {
13760
13958
  currentHookNameInDev = 'useEffect';
13761
13959
  warnInvalidHookAccess();
13960
+ updateHookTypesDev();
13762
13961
  return updateEffect(create, deps);
13763
13962
  },
13764
13963
  useImperativeHandle: function (ref, create, deps) {
13765
13964
  currentHookNameInDev = 'useImperativeHandle';
13766
13965
  warnInvalidHookAccess();
13966
+ updateHookTypesDev();
13767
13967
  return updateImperativeHandle(ref, create, deps);
13768
13968
  },
13769
13969
  useLayoutEffect: function (create, deps) {
13770
13970
  currentHookNameInDev = 'useLayoutEffect';
13771
13971
  warnInvalidHookAccess();
13972
+ updateHookTypesDev();
13772
13973
  return updateLayoutEffect(create, deps);
13773
13974
  },
13774
13975
  useMemo: function (create, deps) {
13775
13976
  currentHookNameInDev = 'useMemo';
13776
13977
  warnInvalidHookAccess();
13978
+ updateHookTypesDev();
13777
13979
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13778
13980
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13779
13981
  try {
@@ -13785,6 +13987,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13785
13987
  useReducer: function (reducer, initialArg, init) {
13786
13988
  currentHookNameInDev = 'useReducer';
13787
13989
  warnInvalidHookAccess();
13990
+ updateHookTypesDev();
13788
13991
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13789
13992
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13790
13993
  try {
@@ -13796,11 +13999,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13796
13999
  useRef: function (initialValue) {
13797
14000
  currentHookNameInDev = 'useRef';
13798
14001
  warnInvalidHookAccess();
14002
+ updateHookTypesDev();
13799
14003
  return updateRef(initialValue);
13800
14004
  },
13801
14005
  useState: function (initialState) {
13802
14006
  currentHookNameInDev = 'useState';
13803
14007
  warnInvalidHookAccess();
14008
+ updateHookTypesDev();
13804
14009
  var prevDispatcher = ReactCurrentDispatcher$1.current;
13805
14010
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
13806
14011
  try {
@@ -13812,6 +14017,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
13812
14017
  useDebugValue: function (value, formatterFn) {
13813
14018
  currentHookNameInDev = 'useDebugValue';
13814
14019
  warnInvalidHookAccess();
14020
+ updateHookTypesDev();
13815
14021
  return updateDebugValue(value, formatterFn);
13816
14022
  }
13817
14023
  };
@@ -17083,11 +17289,11 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) {
17083
17289
  if (_destroy === null) {
17084
17290
  addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
17085
17291
  } else if (typeof _destroy.then === 'function') {
17086
- 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.";
17292
+ 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';
17087
17293
  } else {
17088
17294
  addendum = ' You returned: ' + _destroy;
17089
17295
  }
17090
- warningWithoutStack$1(false, 'An Effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
17296
+ warningWithoutStack$1(false, 'An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
17091
17297
  }
17092
17298
  }
17093
17299
  }
@@ -20546,7 +20752,7 @@ implementation) {
20546
20752
 
20547
20753
  // TODO: this is special because it gets imported during build.
20548
20754
 
20549
- var ReactVersion = '16.8.2';
20755
+ var ReactVersion = '16.8.6';
20550
20756
 
20551
20757
  // TODO: This type is shared between the reconciler and ReactDOM, but will
20552
20758
  // eventually be lifted out to the renderer.