react-test-renderer 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.
@@ -1,4 +1,4 @@
1
- /** @license React v16.8.2
1
+ /** @license React v16.8.6
2
2
  * react-test-renderer.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -1865,6 +1865,7 @@ function FiberNode(tag, pendingProps, key, mode) {
1865
1865
  this._debugSource = null;
1866
1866
  this._debugOwner = null;
1867
1867
  this._debugIsCurrentlyTiming = false;
1868
+ this._debugHookTypes = null;
1868
1869
  if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
1869
1870
  Object.preventExtensions(this);
1870
1871
  }
@@ -1932,6 +1933,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
1932
1933
  workInProgress._debugID = current._debugID;
1933
1934
  workInProgress._debugSource = current._debugSource;
1934
1935
  workInProgress._debugOwner = current._debugOwner;
1936
+ workInProgress._debugHookTypes = current._debugHookTypes;
1935
1937
  }
1936
1938
 
1937
1939
  workInProgress.alternate = current;
@@ -2199,6 +2201,7 @@ function assignFiberPropertiesInDEV(target, source) {
2199
2201
  target._debugSource = source._debugSource;
2200
2202
  target._debugOwner = source._debugOwner;
2201
2203
  target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
2204
+ target._debugHookTypes = source._debugHookTypes;
2202
2205
  return target;
2203
2206
  }
2204
2207
 
@@ -3409,14 +3412,35 @@ function constructClassInstance(workInProgress, ctor, props, renderExpirationTim
3409
3412
  var unmaskedContext = emptyContextObject;
3410
3413
  var context = null;
3411
3414
  var contextType = ctor.contextType;
3412
- if (typeof contextType === 'object' && contextType !== null) {
3413
- {
3414
- if (contextType.$$typeof !== REACT_CONTEXT_TYPE && !didWarnAboutInvalidateContextType.has(ctor)) {
3415
+
3416
+ {
3417
+ if ('contextType' in ctor) {
3418
+ var isValid =
3419
+ // Allow null for conditional declaration
3420
+ contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer>
3421
+
3422
+ if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
3415
3423
  didWarnAboutInvalidateContextType.add(ctor);
3416
- 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');
3424
+
3425
+ var addendum = '';
3426
+ if (contextType === undefined) {
3427
+ 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.';
3428
+ } else if (typeof contextType !== 'object') {
3429
+ addendum = ' However, it is set to a ' + typeof contextType + '.';
3430
+ } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
3431
+ addendum = ' Did you accidentally pass the Context.Provider instead?';
3432
+ } else if (contextType._context !== undefined) {
3433
+ // <Context.Consumer>
3434
+ addendum = ' Did you accidentally pass the Context.Consumer instead?';
3435
+ } else {
3436
+ addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
3437
+ }
3438
+ warningWithoutStack$1(false, '%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum);
3417
3439
  }
3418
3440
  }
3441
+ }
3419
3442
 
3443
+ if (typeof contextType === 'object' && contextType !== null) {
3420
3444
  context = readContext(contextType);
3421
3445
  } else {
3422
3446
  unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
@@ -4843,7 +4867,6 @@ var currentlyRenderingFiber$1 = null;
4843
4867
  // current hook list is the list that belongs to the current fiber. The
4844
4868
  // work-in-progress hook list is a new list that will be added to the
4845
4869
  // work-in-progress fiber.
4846
- var firstCurrentHook = null;
4847
4870
  var currentHook = null;
4848
4871
  var nextCurrentHook = null;
4849
4872
  var firstWorkInProgressHook = null;
@@ -4873,45 +4896,73 @@ var RE_RENDER_LIMIT = 25;
4873
4896
  // In DEV, this is the name of the currently executing primitive hook
4874
4897
  var currentHookNameInDev = null;
4875
4898
 
4876
- function warnOnHookMismatchInDev() {
4899
+ // In DEV, this list ensures that hooks are called in the same order between renders.
4900
+ // The list stores the order of hooks used during the initial render (mount).
4901
+ // Subsequent renders (updates) reference this list.
4902
+ var hookTypesDev = null;
4903
+ var hookTypesUpdateIndexDev = -1;
4904
+
4905
+ function mountHookTypesDev() {
4906
+ {
4907
+ var hookName = currentHookNameInDev;
4908
+
4909
+ if (hookTypesDev === null) {
4910
+ hookTypesDev = [hookName];
4911
+ } else {
4912
+ hookTypesDev.push(hookName);
4913
+ }
4914
+ }
4915
+ }
4916
+
4917
+ function updateHookTypesDev() {
4918
+ {
4919
+ var hookName = currentHookNameInDev;
4920
+
4921
+ if (hookTypesDev !== null) {
4922
+ hookTypesUpdateIndexDev++;
4923
+ if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
4924
+ warnOnHookMismatchInDev(hookName);
4925
+ }
4926
+ }
4927
+ }
4928
+ }
4929
+
4930
+ function warnOnHookMismatchInDev(currentHookName) {
4877
4931
  {
4878
4932
  var componentName = getComponentName(currentlyRenderingFiber$1.type);
4879
4933
  if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
4880
4934
  didWarnAboutMismatchedHooksForComponent.add(componentName);
4881
4935
 
4882
- var secondColumnStart = 22;
4936
+ if (hookTypesDev !== null) {
4937
+ var table = '';
4883
4938
 
4884
- var table = '';
4885
- var prevHook = firstCurrentHook;
4886
- var nextHook = firstWorkInProgressHook;
4887
- var n = 1;
4888
- while (prevHook !== null && nextHook !== null) {
4889
- var oldHookName = prevHook._debugType;
4890
- var newHookName = nextHook._debugType;
4939
+ var secondColumnStart = 30;
4891
4940
 
4892
- var row = n + '. ' + oldHookName;
4941
+ for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
4942
+ var oldHookName = hookTypesDev[i];
4943
+ var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
4893
4944
 
4894
- // Extra space so second column lines up
4895
- // lol @ IE not supporting String#repeat
4896
- while (row.length < secondColumnStart) {
4897
- row += ' ';
4898
- }
4945
+ var row = i + 1 + '. ' + oldHookName;
4899
4946
 
4900
- row += newHookName + '\n';
4947
+ // Extra space so second column lines up
4948
+ // lol @ IE not supporting String#repeat
4949
+ while (row.length < secondColumnStart) {
4950
+ row += ' ';
4951
+ }
4901
4952
 
4902
- table += row;
4903
- prevHook = prevHook.next;
4904
- nextHook = nextHook.next;
4905
- n++;
4906
- }
4953
+ row += newHookName + '\n';
4907
4954
 
4908
- 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);
4955
+ table += row;
4956
+ }
4957
+
4958
+ 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);
4959
+ }
4909
4960
  }
4910
4961
  }
4911
4962
  }
4912
4963
 
4913
4964
  function throwInvalidHookError() {
4914
- invariant(false, 'Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)');
4965
+ 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.');
4915
4966
  }
4916
4967
 
4917
4968
  function areHookInputsEqual(nextDeps, prevDeps) {
@@ -4941,7 +4992,12 @@ function areHookInputsEqual(nextDeps, prevDeps) {
4941
4992
  function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
4942
4993
  renderExpirationTime = nextRenderExpirationTime;
4943
4994
  currentlyRenderingFiber$1 = workInProgress;
4944
- firstCurrentHook = nextCurrentHook = current !== null ? current.memoizedState : null;
4995
+ nextCurrentHook = current !== null ? current.memoizedState : null;
4996
+
4997
+ {
4998
+ hookTypesDev = current !== null ? current._debugHookTypes : null;
4999
+ hookTypesUpdateIndexDev = -1;
5000
+ }
4945
5001
 
4946
5002
  // The following should have already been reset
4947
5003
  // currentHook = null;
@@ -4955,8 +5011,26 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
4955
5011
  // numberOfReRenders = 0;
4956
5012
  // sideEffectTag = 0;
4957
5013
 
5014
+ // TODO Warn if no hooks are used at all during mount, then some are used during update.
5015
+ // Currently we will identify the update render as a mount because nextCurrentHook === null.
5016
+ // This is tricky because it's valid for certain types of components (e.g. React.lazy)
5017
+
5018
+ // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used.
5019
+ // Non-stateful hooks (e.g. context) don't get added to memoizedState,
5020
+ // so nextCurrentHook would be null during updates and mounts.
4958
5021
  {
4959
- ReactCurrentDispatcher$1.current = nextCurrentHook === null ? HooksDispatcherOnMountInDEV : HooksDispatcherOnUpdateInDEV;
5022
+ if (nextCurrentHook !== null) {
5023
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
5024
+ } else if (hookTypesDev !== null) {
5025
+ // This dispatcher handles an edge case where a component is updating,
5026
+ // but no stateful hooks have been used.
5027
+ // We want to match the production code behavior (which will use HooksDispatcherOnMount),
5028
+ // but with the extra DEV validation to ensure hooks ordering hasn't changed.
5029
+ // This dispatcher does that.
5030
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
5031
+ } else {
5032
+ ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
5033
+ }
4960
5034
  }
4961
5035
 
4962
5036
  var children = Component(props, refOrContext);
@@ -4967,13 +5041,18 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
4967
5041
  numberOfReRenders += 1;
4968
5042
 
4969
5043
  // Start over from the beginning of the list
4970
- firstCurrentHook = nextCurrentHook = current !== null ? current.memoizedState : null;
5044
+ nextCurrentHook = current !== null ? current.memoizedState : null;
4971
5045
  nextWorkInProgressHook = firstWorkInProgressHook;
4972
5046
 
4973
5047
  currentHook = null;
4974
5048
  workInProgressHook = null;
4975
5049
  componentUpdateQueue = null;
4976
5050
 
5051
+ {
5052
+ // Also validate hook order for cascading updates.
5053
+ hookTypesUpdateIndexDev = -1;
5054
+ }
5055
+
4977
5056
  ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
4978
5057
 
4979
5058
  children = Component(props, refOrContext);
@@ -4983,10 +5062,6 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
4983
5062
  numberOfReRenders = 0;
4984
5063
  }
4985
5064
 
4986
- {
4987
- currentHookNameInDev = null;
4988
- }
4989
-
4990
5065
  // We can assume the previous dispatcher is always this one, since we set it
4991
5066
  // at the beginning of the render phase and there's no re-entrancy.
4992
5067
  ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
@@ -4998,18 +5073,29 @@ function renderWithHooks(current, workInProgress, Component, props, refOrContext
4998
5073
  renderedWork.updateQueue = componentUpdateQueue;
4999
5074
  renderedWork.effectTag |= sideEffectTag;
5000
5075
 
5076
+ {
5077
+ renderedWork._debugHookTypes = hookTypesDev;
5078
+ }
5079
+
5080
+ // This check uses currentHook so that it works the same in DEV and prod bundles.
5081
+ // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
5001
5082
  var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
5002
5083
 
5003
5084
  renderExpirationTime = NoWork;
5004
5085
  currentlyRenderingFiber$1 = null;
5005
5086
 
5006
- firstCurrentHook = null;
5007
5087
  currentHook = null;
5008
5088
  nextCurrentHook = null;
5009
5089
  firstWorkInProgressHook = null;
5010
5090
  workInProgressHook = null;
5011
5091
  nextWorkInProgressHook = null;
5012
5092
 
5093
+ {
5094
+ currentHookNameInDev = null;
5095
+ hookTypesDev = null;
5096
+ hookTypesUpdateIndexDev = -1;
5097
+ }
5098
+
5013
5099
  remainingExpirationTime = NoWork;
5014
5100
  componentUpdateQueue = null;
5015
5101
  sideEffectTag = 0;
@@ -5043,21 +5129,23 @@ function resetHooks() {
5043
5129
  renderExpirationTime = NoWork;
5044
5130
  currentlyRenderingFiber$1 = null;
5045
5131
 
5046
- firstCurrentHook = null;
5047
5132
  currentHook = null;
5048
5133
  nextCurrentHook = null;
5049
5134
  firstWorkInProgressHook = null;
5050
5135
  workInProgressHook = null;
5051
5136
  nextWorkInProgressHook = null;
5052
5137
 
5053
- remainingExpirationTime = NoWork;
5054
- componentUpdateQueue = null;
5055
- sideEffectTag = 0;
5056
-
5057
5138
  {
5139
+ hookTypesDev = null;
5140
+ hookTypesUpdateIndexDev = -1;
5141
+
5058
5142
  currentHookNameInDev = null;
5059
5143
  }
5060
5144
 
5145
+ remainingExpirationTime = NoWork;
5146
+ componentUpdateQueue = null;
5147
+ sideEffectTag = 0;
5148
+
5061
5149
  didScheduleRenderPhaseUpdate = false;
5062
5150
  renderPhaseUpdates = null;
5063
5151
  numberOfReRenders = 0;
@@ -5074,9 +5162,6 @@ function mountWorkInProgressHook() {
5074
5162
  next: null
5075
5163
  };
5076
5164
 
5077
- {
5078
- hook._debugType = currentHookNameInDev;
5079
- }
5080
5165
  if (workInProgressHook === null) {
5081
5166
  // This is the first hook in the list
5082
5167
  firstWorkInProgressHook = workInProgressHook = hook;
@@ -5123,13 +5208,6 @@ function updateWorkInProgressHook() {
5123
5208
  workInProgressHook = workInProgressHook.next = newHook;
5124
5209
  }
5125
5210
  nextCurrentHook = currentHook.next;
5126
-
5127
- {
5128
- newHook._debugType = currentHookNameInDev;
5129
- if (currentHookNameInDev !== currentHook._debugType) {
5130
- warnOnHookMismatchInDev();
5131
- }
5132
- }
5133
5211
  }
5134
5212
  return workInProgressHook;
5135
5213
  }
@@ -5144,20 +5222,6 @@ function basicStateReducer(state, action) {
5144
5222
  return typeof action === 'function' ? action(state) : action;
5145
5223
  }
5146
5224
 
5147
- function mountContext(context, observedBits) {
5148
- {
5149
- mountWorkInProgressHook();
5150
- }
5151
- return readContext(context, observedBits);
5152
- }
5153
-
5154
- function updateContext(context, observedBits) {
5155
- {
5156
- updateWorkInProgressHook();
5157
- }
5158
- return readContext(context, observedBits);
5159
- }
5160
-
5161
5225
  function mountReducer(reducer, initialArg, init) {
5162
5226
  var hook = mountWorkInProgressHook();
5163
5227
  var initialState = void 0;
@@ -5170,8 +5234,8 @@ function mountReducer(reducer, initialArg, init) {
5170
5234
  var queue = hook.queue = {
5171
5235
  last: null,
5172
5236
  dispatch: null,
5173
- eagerReducer: reducer,
5174
- eagerState: initialState
5237
+ lastRenderedReducer: reducer,
5238
+ lastRenderedState: initialState
5175
5239
  };
5176
5240
  var dispatch = queue.dispatch = dispatchAction.bind(null,
5177
5241
  // Flow doesn't know this is non-null, but we do.
@@ -5184,6 +5248,8 @@ function updateReducer(reducer, initialArg, init) {
5184
5248
  var queue = hook.queue;
5185
5249
  !(queue !== null) ? invariant(false, 'Should have a queue. This is likely a bug in React. Please file an issue.') : void 0;
5186
5250
 
5251
+ queue.lastRenderedReducer = reducer;
5252
+
5187
5253
  if (numberOfReRenders > 0) {
5188
5254
  // This is a re-render. Apply the new render phase updates to the previous
5189
5255
  var _dispatch = queue.dispatch;
@@ -5210,7 +5276,6 @@ function updateReducer(reducer, initialArg, init) {
5210
5276
  }
5211
5277
 
5212
5278
  hook.memoizedState = newState;
5213
-
5214
5279
  // Don't persist the state accumlated from the render phase updates to
5215
5280
  // the base state unless the queue is empty.
5216
5281
  // TODO: Not sure if this is the desired semantics, but it's what we
@@ -5219,6 +5284,8 @@ function updateReducer(reducer, initialArg, init) {
5219
5284
  hook.baseState = newState;
5220
5285
  }
5221
5286
 
5287
+ queue.lastRenderedState = newState;
5288
+
5222
5289
  return [newState, _dispatch];
5223
5290
  }
5224
5291
  }
@@ -5296,8 +5363,7 @@ function updateReducer(reducer, initialArg, init) {
5296
5363
  hook.baseUpdate = newBaseUpdate;
5297
5364
  hook.baseState = newBaseState;
5298
5365
 
5299
- queue.eagerReducer = reducer;
5300
- queue.eagerState = _newState;
5366
+ queue.lastRenderedState = _newState;
5301
5367
  }
5302
5368
 
5303
5369
  var dispatch = queue.dispatch;
@@ -5313,8 +5379,8 @@ function mountState(initialState) {
5313
5379
  var queue = hook.queue = {
5314
5380
  last: null,
5315
5381
  dispatch: null,
5316
- eagerReducer: basicStateReducer,
5317
- eagerState: initialState
5382
+ lastRenderedReducer: basicStateReducer,
5383
+ lastRenderedState: initialState
5318
5384
  };
5319
5385
  var dispatch = queue.dispatch = dispatchAction.bind(null,
5320
5386
  // Flow doesn't know this is non-null, but we do.
@@ -5591,21 +5657,21 @@ function dispatchAction(fiber, queue, action) {
5591
5657
  // The queue is currently empty, which means we can eagerly compute the
5592
5658
  // next state before entering the render phase. If the new state is the
5593
5659
  // same as the current state, we may be able to bail out entirely.
5594
- var _eagerReducer = queue.eagerReducer;
5595
- if (_eagerReducer !== null) {
5660
+ var _lastRenderedReducer = queue.lastRenderedReducer;
5661
+ if (_lastRenderedReducer !== null) {
5596
5662
  var prevDispatcher = void 0;
5597
5663
  {
5598
5664
  prevDispatcher = ReactCurrentDispatcher$1.current;
5599
5665
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
5600
5666
  }
5601
5667
  try {
5602
- var currentState = queue.eagerState;
5603
- var _eagerState = _eagerReducer(currentState, action);
5668
+ var currentState = queue.lastRenderedState;
5669
+ var _eagerState = _lastRenderedReducer(currentState, action);
5604
5670
  // Stash the eagerly computed state, and the reducer used to compute
5605
5671
  // it, on the update object. If the reducer hasn't changed by the
5606
5672
  // time we enter the render phase, then the eager state can be used
5607
5673
  // without calling the reducer again.
5608
- _update2.eagerReducer = _eagerReducer;
5674
+ _update2.eagerReducer = _lastRenderedReducer;
5609
5675
  _update2.eagerState = _eagerState;
5610
5676
  if (is(_eagerState, currentState)) {
5611
5677
  // Fast path. We can bail out without scheduling React to re-render.
@@ -5648,6 +5714,7 @@ var ContextOnlyDispatcher = {
5648
5714
  };
5649
5715
 
5650
5716
  var HooksDispatcherOnMountInDEV = null;
5717
+ var HooksDispatcherOnMountWithHookTypesInDEV = null;
5651
5718
  var HooksDispatcherOnUpdateInDEV = null;
5652
5719
  var InvalidNestedHooksDispatcherOnMountInDEV = null;
5653
5720
  var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
@@ -5667,26 +5734,106 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5667
5734
  },
5668
5735
  useCallback: function (callback, deps) {
5669
5736
  currentHookNameInDev = 'useCallback';
5737
+ mountHookTypesDev();
5738
+ return mountCallback(callback, deps);
5739
+ },
5740
+ useContext: function (context, observedBits) {
5741
+ currentHookNameInDev = 'useContext';
5742
+ mountHookTypesDev();
5743
+ return readContext(context, observedBits);
5744
+ },
5745
+ useEffect: function (create, deps) {
5746
+ currentHookNameInDev = 'useEffect';
5747
+ mountHookTypesDev();
5748
+ return mountEffect(create, deps);
5749
+ },
5750
+ useImperativeHandle: function (ref, create, deps) {
5751
+ currentHookNameInDev = 'useImperativeHandle';
5752
+ mountHookTypesDev();
5753
+ return mountImperativeHandle(ref, create, deps);
5754
+ },
5755
+ useLayoutEffect: function (create, deps) {
5756
+ currentHookNameInDev = 'useLayoutEffect';
5757
+ mountHookTypesDev();
5758
+ return mountLayoutEffect(create, deps);
5759
+ },
5760
+ useMemo: function (create, deps) {
5761
+ currentHookNameInDev = 'useMemo';
5762
+ mountHookTypesDev();
5763
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
5764
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5765
+ try {
5766
+ return mountMemo(create, deps);
5767
+ } finally {
5768
+ ReactCurrentDispatcher$1.current = prevDispatcher;
5769
+ }
5770
+ },
5771
+ useReducer: function (reducer, initialArg, init) {
5772
+ currentHookNameInDev = 'useReducer';
5773
+ mountHookTypesDev();
5774
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
5775
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5776
+ try {
5777
+ return mountReducer(reducer, initialArg, init);
5778
+ } finally {
5779
+ ReactCurrentDispatcher$1.current = prevDispatcher;
5780
+ }
5781
+ },
5782
+ useRef: function (initialValue) {
5783
+ currentHookNameInDev = 'useRef';
5784
+ mountHookTypesDev();
5785
+ return mountRef(initialValue);
5786
+ },
5787
+ useState: function (initialState) {
5788
+ currentHookNameInDev = 'useState';
5789
+ mountHookTypesDev();
5790
+ var prevDispatcher = ReactCurrentDispatcher$1.current;
5791
+ ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5792
+ try {
5793
+ return mountState(initialState);
5794
+ } finally {
5795
+ ReactCurrentDispatcher$1.current = prevDispatcher;
5796
+ }
5797
+ },
5798
+ useDebugValue: function (value, formatterFn) {
5799
+ currentHookNameInDev = 'useDebugValue';
5800
+ mountHookTypesDev();
5801
+ return mountDebugValue(value, formatterFn);
5802
+ }
5803
+ };
5804
+
5805
+ HooksDispatcherOnMountWithHookTypesInDEV = {
5806
+ readContext: function (context, observedBits) {
5807
+ return readContext(context, observedBits);
5808
+ },
5809
+ useCallback: function (callback, deps) {
5810
+ currentHookNameInDev = 'useCallback';
5811
+ updateHookTypesDev();
5670
5812
  return mountCallback(callback, deps);
5671
5813
  },
5672
5814
  useContext: function (context, observedBits) {
5673
5815
  currentHookNameInDev = 'useContext';
5674
- return mountContext(context, observedBits);
5816
+ updateHookTypesDev();
5817
+ return readContext(context, observedBits);
5675
5818
  },
5676
5819
  useEffect: function (create, deps) {
5677
5820
  currentHookNameInDev = 'useEffect';
5821
+ updateHookTypesDev();
5678
5822
  return mountEffect(create, deps);
5679
5823
  },
5680
5824
  useImperativeHandle: function (ref, create, deps) {
5681
5825
  currentHookNameInDev = 'useImperativeHandle';
5826
+ updateHookTypesDev();
5682
5827
  return mountImperativeHandle(ref, create, deps);
5683
5828
  },
5684
5829
  useLayoutEffect: function (create, deps) {
5685
5830
  currentHookNameInDev = 'useLayoutEffect';
5831
+ updateHookTypesDev();
5686
5832
  return mountLayoutEffect(create, deps);
5687
5833
  },
5688
5834
  useMemo: function (create, deps) {
5689
5835
  currentHookNameInDev = 'useMemo';
5836
+ updateHookTypesDev();
5690
5837
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5691
5838
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5692
5839
  try {
@@ -5697,6 +5844,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5697
5844
  },
5698
5845
  useReducer: function (reducer, initialArg, init) {
5699
5846
  currentHookNameInDev = 'useReducer';
5847
+ updateHookTypesDev();
5700
5848
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5701
5849
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5702
5850
  try {
@@ -5707,10 +5855,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5707
5855
  },
5708
5856
  useRef: function (initialValue) {
5709
5857
  currentHookNameInDev = 'useRef';
5858
+ updateHookTypesDev();
5710
5859
  return mountRef(initialValue);
5711
5860
  },
5712
5861
  useState: function (initialState) {
5713
5862
  currentHookNameInDev = 'useState';
5863
+ updateHookTypesDev();
5714
5864
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5715
5865
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5716
5866
  try {
@@ -5721,6 +5871,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5721
5871
  },
5722
5872
  useDebugValue: function (value, formatterFn) {
5723
5873
  currentHookNameInDev = 'useDebugValue';
5874
+ updateHookTypesDev();
5724
5875
  return mountDebugValue(value, formatterFn);
5725
5876
  }
5726
5877
  };
@@ -5731,26 +5882,32 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5731
5882
  },
5732
5883
  useCallback: function (callback, deps) {
5733
5884
  currentHookNameInDev = 'useCallback';
5885
+ updateHookTypesDev();
5734
5886
  return updateCallback(callback, deps);
5735
5887
  },
5736
5888
  useContext: function (context, observedBits) {
5737
5889
  currentHookNameInDev = 'useContext';
5738
- return updateContext(context, observedBits);
5890
+ updateHookTypesDev();
5891
+ return readContext(context, observedBits);
5739
5892
  },
5740
5893
  useEffect: function (create, deps) {
5741
5894
  currentHookNameInDev = 'useEffect';
5895
+ updateHookTypesDev();
5742
5896
  return updateEffect(create, deps);
5743
5897
  },
5744
5898
  useImperativeHandle: function (ref, create, deps) {
5745
5899
  currentHookNameInDev = 'useImperativeHandle';
5900
+ updateHookTypesDev();
5746
5901
  return updateImperativeHandle(ref, create, deps);
5747
5902
  },
5748
5903
  useLayoutEffect: function (create, deps) {
5749
5904
  currentHookNameInDev = 'useLayoutEffect';
5905
+ updateHookTypesDev();
5750
5906
  return updateLayoutEffect(create, deps);
5751
5907
  },
5752
5908
  useMemo: function (create, deps) {
5753
5909
  currentHookNameInDev = 'useMemo';
5910
+ updateHookTypesDev();
5754
5911
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5755
5912
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
5756
5913
  try {
@@ -5761,6 +5918,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5761
5918
  },
5762
5919
  useReducer: function (reducer, initialArg, init) {
5763
5920
  currentHookNameInDev = 'useReducer';
5921
+ updateHookTypesDev();
5764
5922
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5765
5923
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
5766
5924
  try {
@@ -5771,10 +5929,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5771
5929
  },
5772
5930
  useRef: function (initialValue) {
5773
5931
  currentHookNameInDev = 'useRef';
5932
+ updateHookTypesDev();
5774
5933
  return updateRef(initialValue);
5775
5934
  },
5776
5935
  useState: function (initialState) {
5777
5936
  currentHookNameInDev = 'useState';
5937
+ updateHookTypesDev();
5778
5938
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5779
5939
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
5780
5940
  try {
@@ -5785,6 +5945,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5785
5945
  },
5786
5946
  useDebugValue: function (value, formatterFn) {
5787
5947
  currentHookNameInDev = 'useDebugValue';
5948
+ updateHookTypesDev();
5788
5949
  return updateDebugValue(value, formatterFn);
5789
5950
  }
5790
5951
  };
@@ -5797,31 +5958,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5797
5958
  useCallback: function (callback, deps) {
5798
5959
  currentHookNameInDev = 'useCallback';
5799
5960
  warnInvalidHookAccess();
5961
+ mountHookTypesDev();
5800
5962
  return mountCallback(callback, deps);
5801
5963
  },
5802
5964
  useContext: function (context, observedBits) {
5803
5965
  currentHookNameInDev = 'useContext';
5804
5966
  warnInvalidHookAccess();
5805
- return mountContext(context, observedBits);
5967
+ mountHookTypesDev();
5968
+ return readContext(context, observedBits);
5806
5969
  },
5807
5970
  useEffect: function (create, deps) {
5808
5971
  currentHookNameInDev = 'useEffect';
5809
5972
  warnInvalidHookAccess();
5973
+ mountHookTypesDev();
5810
5974
  return mountEffect(create, deps);
5811
5975
  },
5812
5976
  useImperativeHandle: function (ref, create, deps) {
5813
5977
  currentHookNameInDev = 'useImperativeHandle';
5814
5978
  warnInvalidHookAccess();
5979
+ mountHookTypesDev();
5815
5980
  return mountImperativeHandle(ref, create, deps);
5816
5981
  },
5817
5982
  useLayoutEffect: function (create, deps) {
5818
5983
  currentHookNameInDev = 'useLayoutEffect';
5819
5984
  warnInvalidHookAccess();
5985
+ mountHookTypesDev();
5820
5986
  return mountLayoutEffect(create, deps);
5821
5987
  },
5822
5988
  useMemo: function (create, deps) {
5823
5989
  currentHookNameInDev = 'useMemo';
5824
5990
  warnInvalidHookAccess();
5991
+ mountHookTypesDev();
5825
5992
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5826
5993
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5827
5994
  try {
@@ -5833,6 +6000,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5833
6000
  useReducer: function (reducer, initialArg, init) {
5834
6001
  currentHookNameInDev = 'useReducer';
5835
6002
  warnInvalidHookAccess();
6003
+ mountHookTypesDev();
5836
6004
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5837
6005
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5838
6006
  try {
@@ -5844,11 +6012,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5844
6012
  useRef: function (initialValue) {
5845
6013
  currentHookNameInDev = 'useRef';
5846
6014
  warnInvalidHookAccess();
6015
+ mountHookTypesDev();
5847
6016
  return mountRef(initialValue);
5848
6017
  },
5849
6018
  useState: function (initialState) {
5850
6019
  currentHookNameInDev = 'useState';
5851
6020
  warnInvalidHookAccess();
6021
+ mountHookTypesDev();
5852
6022
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5853
6023
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
5854
6024
  try {
@@ -5860,6 +6030,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5860
6030
  useDebugValue: function (value, formatterFn) {
5861
6031
  currentHookNameInDev = 'useDebugValue';
5862
6032
  warnInvalidHookAccess();
6033
+ mountHookTypesDev();
5863
6034
  return mountDebugValue(value, formatterFn);
5864
6035
  }
5865
6036
  };
@@ -5872,31 +6043,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5872
6043
  useCallback: function (callback, deps) {
5873
6044
  currentHookNameInDev = 'useCallback';
5874
6045
  warnInvalidHookAccess();
6046
+ updateHookTypesDev();
5875
6047
  return updateCallback(callback, deps);
5876
6048
  },
5877
6049
  useContext: function (context, observedBits) {
5878
6050
  currentHookNameInDev = 'useContext';
5879
6051
  warnInvalidHookAccess();
5880
- return updateContext(context, observedBits);
6052
+ updateHookTypesDev();
6053
+ return readContext(context, observedBits);
5881
6054
  },
5882
6055
  useEffect: function (create, deps) {
5883
6056
  currentHookNameInDev = 'useEffect';
5884
6057
  warnInvalidHookAccess();
6058
+ updateHookTypesDev();
5885
6059
  return updateEffect(create, deps);
5886
6060
  },
5887
6061
  useImperativeHandle: function (ref, create, deps) {
5888
6062
  currentHookNameInDev = 'useImperativeHandle';
5889
6063
  warnInvalidHookAccess();
6064
+ updateHookTypesDev();
5890
6065
  return updateImperativeHandle(ref, create, deps);
5891
6066
  },
5892
6067
  useLayoutEffect: function (create, deps) {
5893
6068
  currentHookNameInDev = 'useLayoutEffect';
5894
6069
  warnInvalidHookAccess();
6070
+ updateHookTypesDev();
5895
6071
  return updateLayoutEffect(create, deps);
5896
6072
  },
5897
6073
  useMemo: function (create, deps) {
5898
6074
  currentHookNameInDev = 'useMemo';
5899
6075
  warnInvalidHookAccess();
6076
+ updateHookTypesDev();
5900
6077
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5901
6078
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
5902
6079
  try {
@@ -5908,6 +6085,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5908
6085
  useReducer: function (reducer, initialArg, init) {
5909
6086
  currentHookNameInDev = 'useReducer';
5910
6087
  warnInvalidHookAccess();
6088
+ updateHookTypesDev();
5911
6089
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5912
6090
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
5913
6091
  try {
@@ -5919,11 +6097,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5919
6097
  useRef: function (initialValue) {
5920
6098
  currentHookNameInDev = 'useRef';
5921
6099
  warnInvalidHookAccess();
6100
+ updateHookTypesDev();
5922
6101
  return updateRef(initialValue);
5923
6102
  },
5924
6103
  useState: function (initialState) {
5925
6104
  currentHookNameInDev = 'useState';
5926
6105
  warnInvalidHookAccess();
6106
+ updateHookTypesDev();
5927
6107
  var prevDispatcher = ReactCurrentDispatcher$1.current;
5928
6108
  ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
5929
6109
  try {
@@ -5935,6 +6115,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
5935
6115
  useDebugValue: function (value, formatterFn) {
5936
6116
  currentHookNameInDev = 'useDebugValue';
5937
6117
  warnInvalidHookAccess();
6118
+ updateHookTypesDev();
5938
6119
  return updateDebugValue(value, formatterFn);
5939
6120
  }
5940
6121
  };
@@ -9206,11 +9387,11 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) {
9206
9387
  if (_destroy === null) {
9207
9388
  addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
9208
9389
  } else if (typeof _destroy.then === 'function') {
9209
- 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.";
9390
+ 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';
9210
9391
  } else {
9211
9392
  addendum = ' You returned: ' + _destroy;
9212
9393
  }
9213
- warningWithoutStack$1(false, 'An Effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
9394
+ warningWithoutStack$1(false, 'An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
9214
9395
  }
9215
9396
  }
9216
9397
  }
@@ -12517,7 +12698,7 @@ function injectIntoDevTools(devToolsConfig) {
12517
12698
 
12518
12699
  // TODO: this is special because it gets imported during build.
12519
12700
 
12520
- var ReactVersion = '16.8.2';
12701
+ var ReactVersion = '16.8.6';
12521
12702
 
12522
12703
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
12523
12704