react-dom 16.3.0-alpha.3 → 16.3.2

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.3.0-alpha.3
1
+ /** @license React v16.3.2
2
2
  * react-dom.development.js
3
3
  *
4
4
  * Copyright (c) 2013-present, Facebook, Inc.
@@ -15,8 +15,8 @@ if (process.env.NODE_ENV !== "production") {
15
15
  (function() {
16
16
  'use strict';
17
17
 
18
- var React = require('react');
19
18
  var invariant = require('fbjs/lib/invariant');
19
+ var React = require('react');
20
20
  var warning = require('fbjs/lib/warning');
21
21
  var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
22
22
  var _assign = require('object-assign');
@@ -29,12 +29,8 @@ var emptyObject = require('fbjs/lib/emptyObject');
29
29
  var hyphenateStyleName = require('fbjs/lib/hyphenateStyleName');
30
30
  var camelizeStyleName = require('fbjs/lib/camelizeStyleName');
31
31
 
32
- /**
33
- * WARNING: DO NOT manually require this module.
34
- * This is a replacement for `invariant(...)` used by the error code system
35
- * and will _only_ be required by the corresponding babel pass.
36
- * It always throws.
37
- */
32
+ // Relying on the `invariant()` implementation lets us
33
+ // have preserve the format and params in the www builds.
38
34
 
39
35
  !React ? invariant(false, 'ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM.') : void 0;
40
36
 
@@ -431,7 +427,7 @@ var injection$1 = {
431
427
  getNodeFromInstance = Injected.getNodeFromInstance;
432
428
 
433
429
  {
434
- warning(getNodeFromInstance && getInstanceFromNode, 'EventPluginUtils.injection.injectComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.');
430
+ !(getNodeFromInstance && getInstanceFromNode) ? warning(false, 'EventPluginUtils.injection.injectComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.') : void 0;
435
431
  }
436
432
  }
437
433
  };
@@ -453,7 +449,7 @@ var validateEventDispatches = void 0;
453
449
  var instancesIsArr = Array.isArray(dispatchInstances);
454
450
  var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0;
455
451
 
456
- warning(instancesIsArr === listenersIsArr && instancesLen === listenersLen, 'EventPluginUtils: Invalid `event`.');
452
+ !(instancesIsArr === listenersIsArr && instancesLen === listenersLen) ? warning(false, 'EventPluginUtils: Invalid `event`.') : void 0;
457
453
  };
458
454
  }
459
455
 
@@ -1006,7 +1002,7 @@ function listenerAtPhase(inst, event, propagationPhase) {
1006
1002
  */
1007
1003
  function accumulateDirectionalDispatches(inst, phase, event) {
1008
1004
  {
1009
- warning(inst, 'Dispatching inst must not be null');
1005
+ !inst ? warning(false, 'Dispatching inst must not be null') : void 0;
1010
1006
  }
1011
1007
  var listener = listenerAtPhase(inst, event, phase);
1012
1008
  if (listener) {
@@ -1376,7 +1372,7 @@ SyntheticEvent.extend = function (Interface) {
1376
1372
  return new Proxy(constructor.apply(that, args), {
1377
1373
  set: function (target, prop, value) {
1378
1374
  if (prop !== 'isPersistent' && !target.constructor.Interface.hasOwnProperty(prop) && shouldBeReleasedProperties.indexOf(prop) === -1) {
1379
- warning(didWarnForAddedNewProperty || target.isPersistent(), "This synthetic event is reused for performance reasons. If you're " + "seeing this, you're adding a new property in the synthetic event object. " + 'The property is never released. See ' + 'https://fb.me/react-event-pooling for more information.');
1375
+ !(didWarnForAddedNewProperty || target.isPersistent()) ? warning(false, "This synthetic event is reused for performance reasons. If you're " + "seeing this, you're adding a new property in the synthetic event object. " + 'The property is never released. See ' + 'https://fb.me/react-event-pooling for more information.') : void 0;
1380
1376
  didWarnForAddedNewProperty = true;
1381
1377
  }
1382
1378
  target[prop] = value;
@@ -1421,7 +1417,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) {
1421
1417
 
1422
1418
  function warn(action, result) {
1423
1419
  var warningCondition = false;
1424
- warning(warningCondition, "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result);
1420
+ !warningCondition ? warning(false, "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result) : void 0;
1425
1421
  }
1426
1422
  }
1427
1423
 
@@ -2231,6 +2227,13 @@ function getComponentName(fiber) {
2231
2227
  case REACT_RETURN_TYPE:
2232
2228
  return 'ReactReturn';
2233
2229
  }
2230
+ if (typeof type === 'object' && type !== null) {
2231
+ switch (type.$$typeof) {
2232
+ case REACT_FORWARD_REF_TYPE:
2233
+ var functionName = type.render.displayName || type.render.name || '';
2234
+ return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
2235
+ }
2236
+ }
2234
2237
  return null;
2235
2238
  }
2236
2239
 
@@ -3438,9 +3441,10 @@ var Callback = /* */32;
3438
3441
  var DidCapture = /* */64;
3439
3442
  var Ref = /* */128;
3440
3443
  var ErrLog = /* */256;
3444
+ var Snapshot = /* */2048;
3441
3445
 
3442
3446
  // Union of all host effects
3443
- var HostEffectMask = /* */511;
3447
+ var HostEffectMask = /* */2559;
3444
3448
 
3445
3449
  var Incomplete = /* */512;
3446
3450
  var ShouldCapture = /* */1024;
@@ -3488,7 +3492,7 @@ function isMounted(component) {
3488
3492
  if (owner !== null && owner.tag === ClassComponent) {
3489
3493
  var ownerFiber = owner;
3490
3494
  var instance = ownerFiber.stateNode;
3491
- warning(instance._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(ownerFiber) || 'A component');
3495
+ !instance._warnedAboutRefsInRender ? warning(false, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(ownerFiber) || 'A component') : void 0;
3492
3496
  instance._warnedAboutRefsInRender = true;
3493
3497
  }
3494
3498
  }
@@ -5419,6 +5423,47 @@ function createFiberFromPortal(portal, mode, expirationTime) {
5419
5423
  return fiber;
5420
5424
  }
5421
5425
 
5426
+ // Used for stashing WIP properties to replay failed work in DEV.
5427
+ function assignFiberPropertiesInDEV(target, source) {
5428
+ if (target === null) {
5429
+ // This Fiber's initial properties will always be overwritten.
5430
+ // We only use a Fiber to ensure the same hidden class so DEV isn't slow.
5431
+ target = createFiber(IndeterminateComponent, null, null, NoContext);
5432
+ }
5433
+
5434
+ // This is intentionally written as a list of all properties.
5435
+ // We tried to use Object.assign() instead but this is called in
5436
+ // the hottest path, and Object.assign() was too slow:
5437
+ // https://github.com/facebook/react/issues/12502
5438
+ // This code is DEV-only so size is not a concern.
5439
+
5440
+ target.tag = source.tag;
5441
+ target.key = source.key;
5442
+ target.type = source.type;
5443
+ target.stateNode = source.stateNode;
5444
+ target['return'] = source['return'];
5445
+ target.child = source.child;
5446
+ target.sibling = source.sibling;
5447
+ target.index = source.index;
5448
+ target.ref = source.ref;
5449
+ target.pendingProps = source.pendingProps;
5450
+ target.memoizedProps = source.memoizedProps;
5451
+ target.updateQueue = source.updateQueue;
5452
+ target.memoizedState = source.memoizedState;
5453
+ target.mode = source.mode;
5454
+ target.effectTag = source.effectTag;
5455
+ target.nextEffect = source.nextEffect;
5456
+ target.firstEffect = source.firstEffect;
5457
+ target.lastEffect = source.lastEffect;
5458
+ target.expirationTime = source.expirationTime;
5459
+ target.alternate = source.alternate;
5460
+ target._debugID = source._debugID;
5461
+ target._debugSource = source._debugSource;
5462
+ target._debugOwner = source._debugOwner;
5463
+ target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
5464
+ return target;
5465
+ }
5466
+
5422
5467
  // TODO: This should be lifted into the renderer.
5423
5468
 
5424
5469
 
@@ -5587,6 +5632,14 @@ var ReactStrictModeWarnings = {
5587
5632
  var didWarnAboutDeprecatedLifecycles = new Set();
5588
5633
  var didWarnAboutUnsafeLifecycles = new Set();
5589
5634
 
5635
+ var setToSortedString = function (set) {
5636
+ var array = [];
5637
+ set.forEach(function (value) {
5638
+ array.push(value);
5639
+ });
5640
+ return array.sort().join(', ');
5641
+ };
5642
+
5590
5643
  ReactStrictModeWarnings.discardPendingWarnings = function () {
5591
5644
  pendingComponentWillMountWarnings = [];
5592
5645
  pendingComponentWillReceivePropsWarnings = [];
@@ -5609,7 +5662,7 @@ var ReactStrictModeWarnings = {
5609
5662
 
5610
5663
  var formatted = lifecycle.replace('UNSAFE_', '');
5611
5664
  var suggestion = LIFECYCLE_SUGGESTIONS[lifecycle];
5612
- var sortedComponentNames = Array.from(componentNames).sort().join(', ');
5665
+ var sortedComponentNames = setToSortedString(componentNames);
5613
5666
 
5614
5667
  lifecyclesWarningMesages.push(formatted + ': Please update the following components to use ' + (suggestion + ' instead: ' + sortedComponentNames));
5615
5668
  }
@@ -5647,7 +5700,7 @@ var ReactStrictModeWarnings = {
5647
5700
  didWarnAboutDeprecatedLifecycles.add(fiber.type);
5648
5701
  });
5649
5702
 
5650
- var sortedNames = Array.from(uniqueNames).sort().join(', ');
5703
+ var sortedNames = setToSortedString(uniqueNames);
5651
5704
 
5652
5705
  lowPriorityWarning$1(false, 'componentWillMount is deprecated and will be removed in the next major version. ' + 'Use componentDidMount instead. As a temporary workaround, ' + 'you can rename to UNSAFE_componentWillMount.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-async-component-lifecycle-hooks', sortedNames);
5653
5706
 
@@ -5661,7 +5714,7 @@ var ReactStrictModeWarnings = {
5661
5714
  didWarnAboutDeprecatedLifecycles.add(fiber.type);
5662
5715
  });
5663
5716
 
5664
- var _sortedNames = Array.from(_uniqueNames).sort().join(', ');
5717
+ var _sortedNames = setToSortedString(_uniqueNames);
5665
5718
 
5666
5719
  lowPriorityWarning$1(false, 'componentWillReceiveProps is deprecated and will be removed in the next major version. ' + 'Use static getDerivedStateFromProps instead.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-async-component-lifecycle-hooks', _sortedNames);
5667
5720
 
@@ -5675,7 +5728,7 @@ var ReactStrictModeWarnings = {
5675
5728
  didWarnAboutDeprecatedLifecycles.add(fiber.type);
5676
5729
  });
5677
5730
 
5678
- var _sortedNames2 = Array.from(_uniqueNames2).sort().join(', ');
5731
+ var _sortedNames2 = setToSortedString(_uniqueNames2);
5679
5732
 
5680
5733
  lowPriorityWarning$1(false, 'componentWillUpdate is deprecated and will be removed in the next major version. ' + 'Use componentDidUpdate instead. As a temporary workaround, ' + 'you can rename to UNSAFE_componentWillUpdate.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-async-component-lifecycle-hooks', _sortedNames2);
5681
5734
 
@@ -5696,7 +5749,7 @@ var ReactStrictModeWarnings = {
5696
5749
  if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
5697
5750
  pendingComponentWillReceivePropsWarnings.push(fiber);
5698
5751
  }
5699
- if (typeof instance.componentWillUpdate === 'function') {
5752
+ if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
5700
5753
  pendingComponentWillUpdateWarnings.push(fiber);
5701
5754
  }
5702
5755
  };
@@ -5753,7 +5806,6 @@ var ReactStrictModeWarnings = {
5753
5806
  }
5754
5807
 
5755
5808
  // Exports ReactDOM.createRoot
5756
- var enableCreateRoot = true;
5757
5809
  var enableUserTimingAPI = true;
5758
5810
 
5759
5811
  // Mutating mode (React DOM, React ART, React Native):
@@ -5910,6 +5962,7 @@ var shouldIgnoreFiber = function (fiber) {
5910
5962
  case Fragment:
5911
5963
  case ContextProvider:
5912
5964
  case ContextConsumer:
5965
+ case Mode:
5913
5966
  return true;
5914
5967
  default:
5915
5968
  return false;
@@ -5979,12 +6032,12 @@ function startRequestCallbackTimer() {
5979
6032
  }
5980
6033
  }
5981
6034
 
5982
- function stopRequestCallbackTimer(didExpire) {
6035
+ function stopRequestCallbackTimer(didExpire, expirationTime) {
5983
6036
  if (enableUserTimingAPI) {
5984
6037
  if (supportsUserTiming) {
5985
6038
  isWaitingForCallback = false;
5986
6039
  var warning$$1 = didExpire ? 'React was blocked by main thread' : null;
5987
- endMark('(Waiting for async callback...)', '(Waiting for async callback...)', warning$$1);
6040
+ endMark('(Waiting for async callback... will force flush in ' + expirationTime + ' ms)', '(Waiting for async callback...)', warning$$1);
5988
6041
  }
5989
6042
  }
5990
6043
  }
@@ -6089,7 +6142,7 @@ function startWorkLoopTimer(nextUnitOfWork) {
6089
6142
  }
6090
6143
  }
6091
6144
 
6092
- function stopWorkLoopTimer(interruptedBy) {
6145
+ function stopWorkLoopTimer(interruptedBy, didCompleteRoot) {
6093
6146
  if (enableUserTimingAPI) {
6094
6147
  if (!supportsUserTiming) {
6095
6148
  return;
@@ -6106,9 +6159,10 @@ function stopWorkLoopTimer(interruptedBy) {
6106
6159
  warning$$1 = 'There were cascading updates';
6107
6160
  }
6108
6161
  commitCountInCurrentWorkLoop = 0;
6162
+ var label = didCompleteRoot ? '(React Tree Reconciliation: Completed Root)' : '(React Tree Reconciliation: Yielded)';
6109
6163
  // Pause any measurements until the next loop.
6110
6164
  pauseTimers();
6111
- endMark('(React Tree Reconciliation)', '(React Tree Reconciliation)', warning$$1);
6165
+ endMark(label, '(React Tree Reconciliation)', warning$$1);
6112
6166
  }
6113
6167
  }
6114
6168
 
@@ -6145,6 +6199,27 @@ function stopCommitTimer() {
6145
6199
  }
6146
6200
  }
6147
6201
 
6202
+ function startCommitSnapshotEffectsTimer() {
6203
+ if (enableUserTimingAPI) {
6204
+ if (!supportsUserTiming) {
6205
+ return;
6206
+ }
6207
+ effectCountInCurrentCommit = 0;
6208
+ beginMark('(Committing Snapshot Effects)');
6209
+ }
6210
+ }
6211
+
6212
+ function stopCommitSnapshotEffectsTimer() {
6213
+ if (enableUserTimingAPI) {
6214
+ if (!supportsUserTiming) {
6215
+ return;
6216
+ }
6217
+ var count = effectCountInCurrentCommit;
6218
+ effectCountInCurrentCommit = 0;
6219
+ endMark('(Committing Snapshot Effects: ' + count + ' Total)', '(Committing Snapshot Effects)', null);
6220
+ }
6221
+ }
6222
+
6148
6223
  function startCommitHostEffectsTimer() {
6149
6224
  if (enableUserTimingAPI) {
6150
6225
  if (!supportsUserTiming) {
@@ -6488,25 +6563,27 @@ var isArray = Array.isArray;
6488
6563
  var didWarnAboutStateAssignmentForComponent = void 0;
6489
6564
  var didWarnAboutUndefinedDerivedState = void 0;
6490
6565
  var didWarnAboutUninitializedState = void 0;
6566
+ var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = void 0;
6491
6567
  var didWarnAboutLegacyLifecyclesAndDerivedState = void 0;
6492
6568
  var warnOnInvalidCallback$1 = void 0;
6493
6569
 
6494
6570
  {
6495
- didWarnAboutStateAssignmentForComponent = {};
6496
- didWarnAboutUndefinedDerivedState = {};
6497
- didWarnAboutUninitializedState = {};
6498
- didWarnAboutLegacyLifecyclesAndDerivedState = {};
6571
+ didWarnAboutStateAssignmentForComponent = new Set();
6572
+ didWarnAboutUndefinedDerivedState = new Set();
6573
+ didWarnAboutUninitializedState = new Set();
6574
+ didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
6575
+ didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
6499
6576
 
6500
- var didWarnOnInvalidCallback = {};
6577
+ var didWarnOnInvalidCallback = new Set();
6501
6578
 
6502
6579
  warnOnInvalidCallback$1 = function (callback, callerName) {
6503
6580
  if (callback === null || typeof callback === 'function') {
6504
6581
  return;
6505
6582
  }
6506
6583
  var key = callerName + '_' + callback;
6507
- if (!didWarnOnInvalidCallback[key]) {
6584
+ if (!didWarnOnInvalidCallback.has(key)) {
6585
+ didWarnOnInvalidCallback.add(key);
6508
6586
  warning(false, '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
6509
- didWarnOnInvalidCallback[key] = true;
6510
6587
  }
6511
6588
  };
6512
6589
 
@@ -6620,7 +6697,7 @@ var ReactFiberClassComponent = function (legacyContext, scheduleWork, computeExp
6620
6697
  stopPhaseTimer();
6621
6698
 
6622
6699
  {
6623
- warning(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(workInProgress) || 'Component');
6700
+ !(shouldUpdate !== undefined) ? warning(false, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(workInProgress) || 'Component') : void 0;
6624
6701
  }
6625
6702
 
6626
6703
  return shouldUpdate;
@@ -6649,40 +6726,48 @@ var ReactFiberClassComponent = function (legacyContext, scheduleWork, computeExp
6649
6726
  }
6650
6727
 
6651
6728
  var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;
6652
- warning(noGetInitialStateOnES6, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name);
6729
+ !noGetInitialStateOnES6 ? warning(false, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name) : void 0;
6653
6730
  var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;
6654
- warning(noGetDefaultPropsOnES6, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name);
6731
+ !noGetDefaultPropsOnES6 ? warning(false, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name) : void 0;
6655
6732
  var noInstancePropTypes = !instance.propTypes;
6656
- warning(noInstancePropTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name);
6733
+ !noInstancePropTypes ? warning(false, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name) : void 0;
6657
6734
  var noInstanceContextTypes = !instance.contextTypes;
6658
- warning(noInstanceContextTypes, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name);
6735
+ !noInstanceContextTypes ? warning(false, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name) : void 0;
6659
6736
  var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';
6660
- warning(noComponentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name);
6737
+ !noComponentShouldUpdate ? warning(false, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name) : void 0;
6661
6738
  if (type.prototype && type.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
6662
6739
  warning(false, '%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentName(workInProgress) || 'A pure component');
6663
6740
  }
6664
6741
  var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';
6665
- warning(noComponentDidUnmount, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name);
6742
+ !noComponentDidUnmount ? warning(false, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name) : void 0;
6666
6743
  var noComponentDidReceiveProps = typeof instance.componentDidReceiveProps !== 'function';
6667
- warning(noComponentDidReceiveProps, '%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name);
6744
+ !noComponentDidReceiveProps ? warning(false, '%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name) : void 0;
6668
6745
  var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';
6669
- warning(noComponentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name);
6746
+ !noComponentWillRecieveProps ? warning(false, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name) : void 0;
6670
6747
  var noUnsafeComponentWillRecieveProps = typeof instance.UNSAFE_componentWillRecieveProps !== 'function';
6671
- warning(noUnsafeComponentWillRecieveProps, '%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name);
6748
+ !noUnsafeComponentWillRecieveProps ? warning(false, '%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name) : void 0;
6672
6749
  var hasMutatedProps = instance.props !== workInProgress.pendingProps;
6673
- warning(instance.props === undefined || !hasMutatedProps, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name);
6750
+ !(instance.props === undefined || !hasMutatedProps) ? warning(false, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name) : void 0;
6674
6751
  var noInstanceDefaultProps = !instance.defaultProps;
6675
- warning(noInstanceDefaultProps, 'Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name);
6752
+ !noInstanceDefaultProps ? warning(false, 'Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name) : void 0;
6753
+
6754
+ if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(type)) {
6755
+ didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(type);
6756
+ warning(false, '%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(workInProgress));
6757
+ }
6758
+
6676
6759
  var noInstanceGetDerivedStateFromProps = typeof instance.getDerivedStateFromProps !== 'function';
6677
- warning(noInstanceGetDerivedStateFromProps, '%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name);
6760
+ !noInstanceGetDerivedStateFromProps ? warning(false, '%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
6678
6761
  var noInstanceGetDerivedStateFromCatch = typeof instance.getDerivedStateFromCatch !== 'function';
6679
- warning(noInstanceGetDerivedStateFromCatch, '%s: getDerivedStateFromCatch() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name);
6762
+ !noInstanceGetDerivedStateFromCatch ? warning(false, '%s: getDerivedStateFromCatch() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
6763
+ var noStaticGetSnapshotBeforeUpdate = typeof type.getSnapshotBeforeUpdate !== 'function';
6764
+ !noStaticGetSnapshotBeforeUpdate ? warning(false, '%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name) : void 0;
6680
6765
  var _state = instance.state;
6681
6766
  if (_state && (typeof _state !== 'object' || isArray(_state))) {
6682
6767
  warning(false, '%s.state: must be set to an object or null', name);
6683
6768
  }
6684
6769
  if (typeof instance.getChildContext === 'function') {
6685
- warning(typeof type.childContextTypes === 'object', '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name);
6770
+ !(typeof type.childContextTypes === 'object') ? warning(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name) : void 0;
6686
6771
  }
6687
6772
  }
6688
6773
  }
@@ -6718,18 +6803,18 @@ var ReactFiberClassComponent = function (legacyContext, scheduleWork, computeExp
6718
6803
  adoptClassInstance(workInProgress, instance);
6719
6804
 
6720
6805
  {
6721
- if (typeof ctor.getDerivedStateFromProps === 'function') {
6722
- if (state === null) {
6723
- var componentName = getComponentName(workInProgress) || 'Component';
6724
- if (!didWarnAboutUninitializedState[componentName]) {
6725
- warning(false, '%s: Did not properly initialize state during construction. ' + 'Expected state to be an object, but it was %s.', componentName, instance.state === null ? 'null' : 'undefined');
6726
- didWarnAboutUninitializedState[componentName] = true;
6727
- }
6806
+ if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) {
6807
+ var componentName = getComponentName(workInProgress) || 'Component';
6808
+ if (!didWarnAboutUninitializedState.has(componentName)) {
6809
+ didWarnAboutUninitializedState.add(componentName);
6810
+ warning(false, '%s: Did not properly initialize state during construction. ' + 'Expected state to be an object, but it was %s.', componentName, instance.state === null ? 'null' : 'undefined');
6728
6811
  }
6812
+ }
6729
6813
 
6730
- // If getDerivedStateFromProps() is defined, "unsafe" lifecycles won't be called.
6731
- // Warn about these lifecycles if they are present.
6732
- // Don't warn about react-lifecycles-compat polyfilled methods though.
6814
+ // If new component APIs are defined, "unsafe" lifecycles won't be called.
6815
+ // Warn about these lifecycles if they are present.
6816
+ // Don't warn about react-lifecycles-compat polyfilled methods though.
6817
+ if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') {
6733
6818
  var foundWillMountName = null;
6734
6819
  var foundWillReceivePropsName = null;
6735
6820
  var foundWillUpdateName = null;
@@ -6743,16 +6828,17 @@ var ReactFiberClassComponent = function (legacyContext, scheduleWork, computeExp
6743
6828
  } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
6744
6829
  foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
6745
6830
  }
6746
- if (typeof instance.componentWillUpdate === 'function') {
6831
+ if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
6747
6832
  foundWillUpdateName = 'componentWillUpdate';
6748
6833
  } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
6749
6834
  foundWillUpdateName = 'UNSAFE_componentWillUpdate';
6750
6835
  }
6751
6836
  if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
6752
6837
  var _componentName = getComponentName(workInProgress) || 'Component';
6753
- if (!didWarnAboutLegacyLifecyclesAndDerivedState[_componentName]) {
6754
- warning(false, 'Unsafe legacy lifecycles will not be called for components using ' + 'the new getDerivedStateFromProps() API.\n\n' + '%s uses getDerivedStateFromProps() but also contains the following legacy lifecycles:' + '%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks', _componentName, foundWillMountName !== null ? '\n ' + foundWillMountName : '', foundWillReceivePropsName !== null ? '\n ' + foundWillReceivePropsName : '', foundWillUpdateName !== null ? '\n ' + foundWillUpdateName : '');
6755
- didWarnAboutLegacyLifecyclesAndDerivedState[_componentName] = true;
6838
+ var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
6839
+ if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
6840
+ didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
6841
+ warning(false, 'Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + '%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks', _componentName, newApiName, foundWillMountName !== null ? '\n ' + foundWillMountName : '', foundWillReceivePropsName !== null ? '\n ' + foundWillReceivePropsName : '', foundWillUpdateName !== null ? '\n ' + foundWillUpdateName : '');
6756
6842
  }
6757
6843
  }
6758
6844
  }
@@ -6813,9 +6899,9 @@ var ReactFiberClassComponent = function (legacyContext, scheduleWork, computeExp
6813
6899
  if (instance.state !== oldState) {
6814
6900
  {
6815
6901
  var componentName = getComponentName(workInProgress) || 'Component';
6816
- if (!didWarnAboutStateAssignmentForComponent[componentName]) {
6902
+ if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
6903
+ didWarnAboutStateAssignmentForComponent.add(componentName);
6817
6904
  warning(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName);
6818
- didWarnAboutStateAssignmentForComponent[componentName] = true;
6819
6905
  }
6820
6906
  }
6821
6907
  updater.enqueueReplaceState(instance, instance.state, null);
@@ -6837,9 +6923,9 @@ var ReactFiberClassComponent = function (legacyContext, scheduleWork, computeExp
6837
6923
  {
6838
6924
  if (partialState === undefined) {
6839
6925
  var componentName = getComponentName(workInProgress) || 'Component';
6840
- if (!didWarnAboutUndefinedDerivedState[componentName]) {
6926
+ if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
6927
+ didWarnAboutUndefinedDerivedState.add(componentName);
6841
6928
  warning(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
6842
- didWarnAboutUndefinedDerivedState[componentName] = componentName;
6843
6929
  }
6844
6930
  }
6845
6931
  }
@@ -6877,8 +6963,8 @@ var ReactFiberClassComponent = function (legacyContext, scheduleWork, computeExp
6877
6963
  }
6878
6964
 
6879
6965
  // In order to support react-lifecycles-compat polyfilled components,
6880
- // Unsafe lifecycles should not be invoked for any component with the new gDSFP.
6881
- if ((typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function') && typeof ctor.getDerivedStateFromProps !== 'function') {
6966
+ // Unsafe lifecycles should not be invoked for components using the new APIs.
6967
+ if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
6882
6968
  callComponentWillMount(workInProgress, instance);
6883
6969
  // If we had additional state updates during this life-cycle, let's
6884
6970
  // process them now.
@@ -6903,13 +6989,15 @@ var ReactFiberClassComponent = function (legacyContext, scheduleWork, computeExp
6903
6989
  var newUnmaskedContext = getUnmaskedContext(workInProgress);
6904
6990
  var newContext = getMaskedContext(workInProgress, newUnmaskedContext);
6905
6991
 
6992
+ var hasNewLifecycles = typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
6993
+
6906
6994
  // Note: During these life-cycles, instance.props/instance.state are what
6907
6995
  // ever the previously attempted to render - not the "current". However,
6908
6996
  // during componentDidUpdate we pass the "current" props.
6909
6997
 
6910
6998
  // In order to support react-lifecycles-compat polyfilled components,
6911
- // Unsafe lifecycles should not be invoked for any component with the new gDSFP.
6912
- if ((typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function') && typeof ctor.getDerivedStateFromProps !== 'function') {
6999
+ // Unsafe lifecycles should not be invoked for components using the new APIs.
7000
+ if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
6913
7001
  if (oldProps !== newProps || oldContext !== newContext) {
6914
7002
  callComponentWillReceiveProps(workInProgress, instance, newProps, newContext);
6915
7003
  }
@@ -6948,12 +7036,26 @@ var ReactFiberClassComponent = function (legacyContext, scheduleWork, computeExp
6948
7036
  // So that multiple render passes do not enqueue multiple updates.
6949
7037
  // Instead, just synchronously merge the returned state into the instance.
6950
7038
  newState = newState === null || newState === undefined ? derivedStateFromProps : _assign({}, newState, derivedStateFromProps);
7039
+
7040
+ // Update the base state of the update queue.
7041
+ // FIXME: This is getting ridiculous. Refactor plz!
7042
+ var _updateQueue = workInProgress.updateQueue;
7043
+ if (_updateQueue !== null) {
7044
+ _updateQueue.baseState = _assign({}, _updateQueue.baseState, derivedStateFromProps);
7045
+ }
6951
7046
  }
6952
7047
  if (derivedStateFromCatch !== null && derivedStateFromCatch !== undefined) {
6953
7048
  // Render-phase updates (like this) should not be added to the update queue,
6954
7049
  // So that multiple render passes do not enqueue multiple updates.
6955
7050
  // Instead, just synchronously merge the returned state into the instance.
6956
7051
  newState = newState === null || newState === undefined ? derivedStateFromCatch : _assign({}, newState, derivedStateFromCatch);
7052
+
7053
+ // Update the base state of the update queue.
7054
+ // FIXME: This is getting ridiculous. Refactor plz!
7055
+ var _updateQueue2 = workInProgress.updateQueue;
7056
+ if (_updateQueue2 !== null) {
7057
+ _updateQueue2.baseState = _assign({}, _updateQueue2.baseState, derivedStateFromCatch);
7058
+ }
6957
7059
  }
6958
7060
 
6959
7061
  if (oldProps === newProps && oldState === newState && !hasContextChanged() && !(workInProgress.updateQueue !== null && workInProgress.updateQueue.hasForceUpdate)) {
@@ -6969,8 +7071,8 @@ var ReactFiberClassComponent = function (legacyContext, scheduleWork, computeExp
6969
7071
 
6970
7072
  if (shouldUpdate) {
6971
7073
  // In order to support react-lifecycles-compat polyfilled components,
6972
- // Unsafe lifecycles should not be invoked for any component with the new gDSFP.
6973
- if ((typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function') && typeof ctor.getDerivedStateFromProps !== 'function') {
7074
+ // Unsafe lifecycles should not be invoked for components using the new APIs.
7075
+ if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
6974
7076
  startPhaseTimer(workInProgress, 'componentWillMount');
6975
7077
  if (typeof instance.componentWillMount === 'function') {
6976
7078
  instance.componentWillMount();
@@ -7017,13 +7119,15 @@ var ReactFiberClassComponent = function (legacyContext, scheduleWork, computeExp
7017
7119
  var newUnmaskedContext = getUnmaskedContext(workInProgress);
7018
7120
  var newContext = getMaskedContext(workInProgress, newUnmaskedContext);
7019
7121
 
7122
+ var hasNewLifecycles = typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
7123
+
7020
7124
  // Note: During these life-cycles, instance.props/instance.state are what
7021
7125
  // ever the previously attempted to render - not the "current". However,
7022
7126
  // during componentDidUpdate we pass the "current" props.
7023
7127
 
7024
7128
  // In order to support react-lifecycles-compat polyfilled components,
7025
- // Unsafe lifecycles should not be invoked for any component with the new gDSFP.
7026
- if ((typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function') && typeof ctor.getDerivedStateFromProps !== 'function') {
7129
+ // Unsafe lifecycles should not be invoked for components using the new APIs.
7130
+ if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
7027
7131
  if (oldProps !== newProps || oldContext !== newContext) {
7028
7132
  callComponentWillReceiveProps(workInProgress, instance, newProps, newContext);
7029
7133
  }
@@ -7034,6 +7138,7 @@ var ReactFiberClassComponent = function (legacyContext, scheduleWork, computeExp
7034
7138
  // TODO: Previous state can be null.
7035
7139
  var newState = void 0;
7036
7140
  var derivedStateFromCatch = void 0;
7141
+
7037
7142
  if (workInProgress.updateQueue !== null) {
7038
7143
  newState = processUpdateQueue(current, workInProgress, workInProgress.updateQueue, instance, newProps, renderExpirationTime);
7039
7144
 
@@ -7062,12 +7167,26 @@ var ReactFiberClassComponent = function (legacyContext, scheduleWork, computeExp
7062
7167
  // So that multiple render passes do not enqueue multiple updates.
7063
7168
  // Instead, just synchronously merge the returned state into the instance.
7064
7169
  newState = newState === null || newState === undefined ? derivedStateFromProps : _assign({}, newState, derivedStateFromProps);
7170
+
7171
+ // Update the base state of the update queue.
7172
+ // FIXME: This is getting ridiculous. Refactor plz!
7173
+ var _updateQueue3 = workInProgress.updateQueue;
7174
+ if (_updateQueue3 !== null) {
7175
+ _updateQueue3.baseState = _assign({}, _updateQueue3.baseState, derivedStateFromProps);
7176
+ }
7065
7177
  }
7066
7178
  if (derivedStateFromCatch !== null && derivedStateFromCatch !== undefined) {
7067
7179
  // Render-phase updates (like this) should not be added to the update queue,
7068
7180
  // So that multiple render passes do not enqueue multiple updates.
7069
7181
  // Instead, just synchronously merge the returned state into the instance.
7070
7182
  newState = newState === null || newState === undefined ? derivedStateFromCatch : _assign({}, newState, derivedStateFromCatch);
7183
+
7184
+ // Update the base state of the update queue.
7185
+ // FIXME: This is getting ridiculous. Refactor plz!
7186
+ var _updateQueue4 = workInProgress.updateQueue;
7187
+ if (_updateQueue4 !== null) {
7188
+ _updateQueue4.baseState = _assign({}, _updateQueue4.baseState, derivedStateFromCatch);
7189
+ }
7071
7190
  }
7072
7191
 
7073
7192
  if (oldProps === newProps && oldState === newState && !hasContextChanged() && !(workInProgress.updateQueue !== null && workInProgress.updateQueue.hasForceUpdate)) {
@@ -7078,6 +7197,11 @@ var ReactFiberClassComponent = function (legacyContext, scheduleWork, computeExp
7078
7197
  workInProgress.effectTag |= Update;
7079
7198
  }
7080
7199
  }
7200
+ if (typeof instance.getSnapshotBeforeUpdate === 'function') {
7201
+ if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
7202
+ workInProgress.effectTag |= Snapshot;
7203
+ }
7204
+ }
7081
7205
  return false;
7082
7206
  }
7083
7207
 
@@ -7085,8 +7209,8 @@ var ReactFiberClassComponent = function (legacyContext, scheduleWork, computeExp
7085
7209
 
7086
7210
  if (shouldUpdate) {
7087
7211
  // In order to support react-lifecycles-compat polyfilled components,
7088
- // Unsafe lifecycles should not be invoked for any component with the new gDSFP.
7089
- if ((typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function') && typeof ctor.getDerivedStateFromProps !== 'function') {
7212
+ // Unsafe lifecycles should not be invoked for components using the new APIs.
7213
+ if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
7090
7214
  startPhaseTimer(workInProgress, 'componentWillUpdate');
7091
7215
  if (typeof instance.componentWillUpdate === 'function') {
7092
7216
  instance.componentWillUpdate(newProps, newState, newContext);
@@ -7099,6 +7223,9 @@ var ReactFiberClassComponent = function (legacyContext, scheduleWork, computeExp
7099
7223
  if (typeof instance.componentDidUpdate === 'function') {
7100
7224
  workInProgress.effectTag |= Update;
7101
7225
  }
7226
+ if (typeof instance.getSnapshotBeforeUpdate === 'function') {
7227
+ workInProgress.effectTag |= Snapshot;
7228
+ }
7102
7229
  } else {
7103
7230
  // If an update was already in progress, we should schedule an Update
7104
7231
  // effect even though we're bailing out, so that cWU/cDU are called.
@@ -7107,6 +7234,11 @@ var ReactFiberClassComponent = function (legacyContext, scheduleWork, computeExp
7107
7234
  workInProgress.effectTag |= Update;
7108
7235
  }
7109
7236
  }
7237
+ if (typeof instance.getSnapshotBeforeUpdate === 'function') {
7238
+ if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
7239
+ workInProgress.effectTag |= Snapshot;
7240
+ }
7241
+ }
7110
7242
 
7111
7243
  // If shouldComponentUpdate returned false, we should still update the
7112
7244
  // memoized props/state to indicate that this work can be reused.
@@ -7735,7 +7867,7 @@ function ChildReconciler(shouldTrackSideEffects) {
7735
7867
  if (typeof newChildrenIterable.entries === 'function') {
7736
7868
  var possibleMap = newChildrenIterable;
7737
7869
  if (possibleMap.entries === iteratorFn) {
7738
- warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$2());
7870
+ !didWarnAboutMaps ? warning(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$2()) : void 0;
7739
7871
  didWarnAboutMaps = true;
7740
7872
  }
7741
7873
  }
@@ -8474,7 +8606,7 @@ var ReactFiberBeginWork = function (config, hostContext, legacyContext, newConte
8474
8606
  var _Component = workInProgress.type;
8475
8607
 
8476
8608
  if (_Component) {
8477
- warning(!_Component.childContextTypes, '%s(...): childContextTypes cannot be defined on a functional component.', _Component.displayName || _Component.name || 'Component');
8609
+ !!_Component.childContextTypes ? warning(false, '%s(...): childContextTypes cannot be defined on a functional component.', _Component.displayName || _Component.name || 'Component') : void 0;
8478
8610
  }
8479
8611
  if (workInProgress.ref !== null) {
8480
8612
  var info = '';
@@ -8640,7 +8772,7 @@ var ReactFiberBeginWork = function (config, hostContext, legacyContext, newConte
8640
8772
 
8641
8773
  function updateContextProvider(current, workInProgress, renderExpirationTime) {
8642
8774
  var providerType = workInProgress.type;
8643
- var context = providerType.context;
8775
+ var context = providerType._context;
8644
8776
 
8645
8777
  var newProps = workInProgress.pendingProps;
8646
8778
  var oldProps = workInProgress.memoizedProps;
@@ -8687,7 +8819,7 @@ var ReactFiberBeginWork = function (config, hostContext, legacyContext, newConte
8687
8819
  } else {
8688
8820
  changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
8689
8821
  {
8690
- warning((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits);
8822
+ !((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits) ? warning(false, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits) : void 0;
8691
8823
  }
8692
8824
  changedBits |= 0;
8693
8825
 
@@ -8741,15 +8873,19 @@ var ReactFiberBeginWork = function (config, hostContext, legacyContext, newConte
8741
8873
  // Context change propagation stops at matching consumers, for time-
8742
8874
  // slicing. Continue the propagation here.
8743
8875
  propagateContextChange(workInProgress, context, changedBits, renderExpirationTime);
8744
- } else if (oldProps !== null && oldProps.children === newProps.children) {
8745
- // No change. Bailout early if children are the same.
8876
+ } else if (oldProps === newProps) {
8877
+ // Skip over a memoized parent with a bitmask bailout even
8878
+ // if we began working on it because of a deeper matching child.
8746
8879
  return bailoutOnAlreadyFinishedWork(current, workInProgress);
8747
8880
  }
8881
+ // There is no bailout on `children` equality because we expect people
8882
+ // to often pass a bound method as a child, but it may reference
8883
+ // `this.state` or `this.props` (and thus needs to re-render on `setState`).
8748
8884
 
8749
8885
  var render = newProps.children;
8750
8886
 
8751
8887
  {
8752
- warning(typeof render === 'function', 'A context consumer was rendered with multiple children, or a child ' + "that isn't a function. A context consumer expects a single child " + 'that is a function. If you did pass a function, make sure there ' + 'is no trailing or leading whitespace around it.');
8888
+ !(typeof render === 'function') ? warning(false, 'A context consumer was rendered with multiple children, or a child ' + "that isn't a function. A context consumer expects a single child " + 'that is a function. If you did pass a function, make sure there ' + 'is no trailing or leading whitespace around it.') : void 0;
8753
8889
  }
8754
8890
 
8755
8891
  var newChildren = render(newValue);
@@ -8904,7 +9040,7 @@ var ReactFiberCompleteWork = function (config, hostContext, legacyContext, newCo
8904
9040
 
8905
9041
  function markUpdate(workInProgress) {
8906
9042
  // Tag the fiber with an update effect. This turns a Placement into
8907
- // an UpdateAndPlacement.
9043
+ // a PlacementAndUpdate.
8908
9044
  workInProgress.effectTag |= Update;
8909
9045
  }
8910
9046
 
@@ -9513,6 +9649,11 @@ var hasCaughtError$1 = ReactErrorUtils.hasCaughtError;
9513
9649
  var clearCaughtError$1 = ReactErrorUtils.clearCaughtError;
9514
9650
 
9515
9651
 
9652
+ var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
9653
+ {
9654
+ didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
9655
+ }
9656
+
9516
9657
  function logError(boundary, errorInfo) {
9517
9658
  var source = errorInfo.source;
9518
9659
  var stack = errorInfo.stack;
@@ -9522,20 +9663,19 @@ function logError(boundary, errorInfo) {
9522
9663
 
9523
9664
  var capturedError = {
9524
9665
  componentName: source !== null ? getComponentName(source) : null,
9525
- error: errorInfo.value,
9526
- errorBoundary: boundary,
9527
9666
  componentStack: stack !== null ? stack : '',
9667
+ error: errorInfo.value,
9668
+ errorBoundary: null,
9528
9669
  errorBoundaryName: null,
9529
9670
  errorBoundaryFound: false,
9530
9671
  willRetry: false
9531
9672
  };
9532
9673
 
9533
- if (boundary !== null) {
9674
+ if (boundary !== null && boundary.tag === ClassComponent) {
9675
+ capturedError.errorBoundary = boundary.stateNode;
9534
9676
  capturedError.errorBoundaryName = getComponentName(boundary);
9535
- capturedError.errorBoundaryFound = capturedError.willRetry = boundary.tag === ClassComponent;
9536
- } else {
9537
- capturedError.errorBoundaryName = null;
9538
- capturedError.errorBoundaryFound = capturedError.willRetry = false;
9677
+ capturedError.errorBoundaryFound = true;
9678
+ capturedError.willRetry = true;
9539
9679
  }
9540
9680
 
9541
9681
  try {
@@ -9592,31 +9732,70 @@ var ReactFiberCommitWork = function (config, captureError, scheduleWork, compute
9592
9732
  }
9593
9733
  }
9594
9734
 
9735
+ function commitBeforeMutationLifeCycles(current, finishedWork) {
9736
+ switch (finishedWork.tag) {
9737
+ case ClassComponent:
9738
+ {
9739
+ if (finishedWork.effectTag & Snapshot) {
9740
+ if (current !== null) {
9741
+ var prevProps = current.memoizedProps;
9742
+ var prevState = current.memoizedState;
9743
+ startPhaseTimer(finishedWork, 'getSnapshotBeforeUpdate');
9744
+ var _instance = finishedWork.stateNode;
9745
+ _instance.props = finishedWork.memoizedProps;
9746
+ _instance.state = finishedWork.memoizedState;
9747
+ var snapshot = _instance.getSnapshotBeforeUpdate(prevProps, prevState);
9748
+ {
9749
+ var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate;
9750
+ if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
9751
+ didWarnSet.add(finishedWork.type);
9752
+ warning(false, '%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork));
9753
+ }
9754
+ }
9755
+ _instance.__reactInternalSnapshotBeforeUpdate = snapshot;
9756
+ stopPhaseTimer();
9757
+ }
9758
+ }
9759
+ return;
9760
+ }
9761
+ case HostRoot:
9762
+ case HostComponent:
9763
+ case HostText:
9764
+ case HostPortal:
9765
+ // Nothing to do for these component types
9766
+ return;
9767
+ default:
9768
+ {
9769
+ invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
9770
+ }
9771
+ }
9772
+ }
9773
+
9595
9774
  function commitLifeCycles(finishedRoot, current, finishedWork, currentTime, committedExpirationTime) {
9596
9775
  switch (finishedWork.tag) {
9597
9776
  case ClassComponent:
9598
9777
  {
9599
- var _instance = finishedWork.stateNode;
9778
+ var _instance2 = finishedWork.stateNode;
9600
9779
  if (finishedWork.effectTag & Update) {
9601
9780
  if (current === null) {
9602
9781
  startPhaseTimer(finishedWork, 'componentDidMount');
9603
- _instance.props = finishedWork.memoizedProps;
9604
- _instance.state = finishedWork.memoizedState;
9605
- _instance.componentDidMount();
9782
+ _instance2.props = finishedWork.memoizedProps;
9783
+ _instance2.state = finishedWork.memoizedState;
9784
+ _instance2.componentDidMount();
9606
9785
  stopPhaseTimer();
9607
9786
  } else {
9608
9787
  var prevProps = current.memoizedProps;
9609
9788
  var prevState = current.memoizedState;
9610
9789
  startPhaseTimer(finishedWork, 'componentDidUpdate');
9611
- _instance.props = finishedWork.memoizedProps;
9612
- _instance.state = finishedWork.memoizedState;
9613
- _instance.componentDidUpdate(prevProps, prevState);
9790
+ _instance2.props = finishedWork.memoizedProps;
9791
+ _instance2.state = finishedWork.memoizedState;
9792
+ _instance2.componentDidUpdate(prevProps, prevState, _instance2.__reactInternalSnapshotBeforeUpdate);
9614
9793
  stopPhaseTimer();
9615
9794
  }
9616
9795
  }
9617
9796
  var updateQueue = finishedWork.updateQueue;
9618
9797
  if (updateQueue !== null) {
9619
- commitCallbacks(updateQueue, _instance);
9798
+ commitCallbacks(updateQueue, _instance2);
9620
9799
  }
9621
9800
  return;
9622
9801
  }
@@ -9624,24 +9803,24 @@ var ReactFiberCommitWork = function (config, captureError, scheduleWork, compute
9624
9803
  {
9625
9804
  var _updateQueue = finishedWork.updateQueue;
9626
9805
  if (_updateQueue !== null) {
9627
- var _instance2 = null;
9806
+ var _instance3 = null;
9628
9807
  if (finishedWork.child !== null) {
9629
9808
  switch (finishedWork.child.tag) {
9630
9809
  case HostComponent:
9631
- _instance2 = getPublicInstance(finishedWork.child.stateNode);
9810
+ _instance3 = getPublicInstance(finishedWork.child.stateNode);
9632
9811
  break;
9633
9812
  case ClassComponent:
9634
- _instance2 = finishedWork.child.stateNode;
9813
+ _instance3 = finishedWork.child.stateNode;
9635
9814
  break;
9636
9815
  }
9637
9816
  }
9638
- commitCallbacks(_updateQueue, _instance2);
9817
+ commitCallbacks(_updateQueue, _instance3);
9639
9818
  }
9640
9819
  return;
9641
9820
  }
9642
9821
  case HostComponent:
9643
9822
  {
9644
- var _instance3 = finishedWork.stateNode;
9823
+ var _instance4 = finishedWork.stateNode;
9645
9824
 
9646
9825
  // Renderers may schedule work to be done after host components are mounted
9647
9826
  // (eg DOM renderer may schedule auto-focus for inputs and form controls).
@@ -9650,7 +9829,7 @@ var ReactFiberCommitWork = function (config, captureError, scheduleWork, compute
9650
9829
  if (current === null && finishedWork.effectTag & Update) {
9651
9830
  var type = finishedWork.type;
9652
9831
  var props = finishedWork.memoizedProps;
9653
- commitMount(_instance3, type, props, finishedWork);
9832
+ commitMount(_instance4, type, props, finishedWork);
9654
9833
  }
9655
9834
 
9656
9835
  return;
@@ -9677,7 +9856,7 @@ var ReactFiberCommitWork = function (config, captureError, scheduleWork, compute
9677
9856
  case ClassComponent:
9678
9857
  {
9679
9858
  var ctor = finishedWork.type;
9680
- var _instance4 = finishedWork.stateNode;
9859
+ var _instance5 = finishedWork.stateNode;
9681
9860
  var updateQueue = finishedWork.updateQueue;
9682
9861
  !(updateQueue !== null && updateQueue.capturedValues !== null) ? invariant(false, 'An error logging effect should not have been scheduled if no errors were captured. This error is likely caused by a bug in React. Please file an issue.') : void 0;
9683
9862
  var capturedErrors = updateQueue.capturedValues;
@@ -9689,17 +9868,17 @@ var ReactFiberCommitWork = function (config, captureError, scheduleWork, compute
9689
9868
  // This gets reset before we yield back to the browser.
9690
9869
  // TODO: Warn in strict mode if getDerivedStateFromCatch is
9691
9870
  // not defined.
9692
- markLegacyErrorBoundaryAsFailed(_instance4);
9871
+ markLegacyErrorBoundaryAsFailed(_instance5);
9693
9872
  }
9694
9873
 
9695
- _instance4.props = finishedWork.memoizedProps;
9696
- _instance4.state = finishedWork.memoizedState;
9874
+ _instance5.props = finishedWork.memoizedProps;
9875
+ _instance5.state = finishedWork.memoizedState;
9697
9876
  for (var i = 0; i < capturedErrors.length; i++) {
9698
9877
  var errorInfo = capturedErrors[i];
9699
9878
  var _error = errorInfo.value;
9700
9879
  var stack = errorInfo.stack;
9701
9880
  logError(finishedWork, errorInfo);
9702
- _instance4.componentDidCatch(_error, {
9881
+ _instance5.componentDidCatch(_error, {
9703
9882
  componentStack: stack !== null ? stack : ''
9704
9883
  });
9705
9884
  }
@@ -9726,14 +9905,14 @@ var ReactFiberCommitWork = function (config, captureError, scheduleWork, compute
9726
9905
  function commitAttachRef(finishedWork) {
9727
9906
  var ref = finishedWork.ref;
9728
9907
  if (ref !== null) {
9729
- var _instance5 = finishedWork.stateNode;
9908
+ var _instance6 = finishedWork.stateNode;
9730
9909
  var instanceToUse = void 0;
9731
9910
  switch (finishedWork.tag) {
9732
9911
  case HostComponent:
9733
- instanceToUse = getPublicInstance(_instance5);
9912
+ instanceToUse = getPublicInstance(_instance6);
9734
9913
  break;
9735
9914
  default:
9736
- instanceToUse = _instance5;
9915
+ instanceToUse = _instance6;
9737
9916
  }
9738
9917
  if (typeof ref === 'function') {
9739
9918
  ref(instanceToUse);
@@ -9772,9 +9951,9 @@ var ReactFiberCommitWork = function (config, captureError, scheduleWork, compute
9772
9951
  case ClassComponent:
9773
9952
  {
9774
9953
  safelyDetachRef(current);
9775
- var _instance6 = current.stateNode;
9776
- if (typeof _instance6.componentWillUnmount === 'function') {
9777
- safelyCallComponentWillUnmount(current, _instance6);
9954
+ var _instance7 = current.stateNode;
9955
+ if (typeof _instance7.componentWillUnmount === 'function') {
9956
+ safelyCallComponentWillUnmount(current, _instance7);
9778
9957
  }
9779
9958
  return;
9780
9959
  }
@@ -9913,6 +10092,7 @@ var ReactFiberCommitWork = function (config, captureError, scheduleWork, compute
9913
10092
  },
9914
10093
 
9915
10094
  commitLifeCycles: commitLifeCycles,
10095
+ commitBeforeMutationLifeCycles: commitBeforeMutationLifeCycles,
9916
10096
  commitErrorLogging: commitErrorLogging,
9917
10097
  commitAttachRef: commitAttachRef,
9918
10098
  commitDetachRef: commitDetachRef
@@ -10158,8 +10338,8 @@ var ReactFiberCommitWork = function (config, captureError, scheduleWork, compute
10158
10338
  }
10159
10339
  case HostComponent:
10160
10340
  {
10161
- var _instance7 = finishedWork.stateNode;
10162
- if (_instance7 != null) {
10341
+ var _instance8 = finishedWork.stateNode;
10342
+ if (_instance8 != null) {
10163
10343
  // Commit the work prepared earlier.
10164
10344
  var newProps = finishedWork.memoizedProps;
10165
10345
  // For hydration we reuse the update path but we treat the oldProps
@@ -10171,7 +10351,7 @@ var ReactFiberCommitWork = function (config, captureError, scheduleWork, compute
10171
10351
  var updatePayload = finishedWork.updateQueue;
10172
10352
  finishedWork.updateQueue = null;
10173
10353
  if (updatePayload !== null) {
10174
- commitUpdate(_instance7, updatePayload, type, oldProps, newProps, finishedWork);
10354
+ commitUpdate(_instance8, updatePayload, type, oldProps, newProps, finishedWork);
10175
10355
  }
10176
10356
  }
10177
10357
  return;
@@ -10205,6 +10385,7 @@ var ReactFiberCommitWork = function (config, captureError, scheduleWork, compute
10205
10385
 
10206
10386
  if (enableMutatingReconciler) {
10207
10387
  return {
10388
+ commitBeforeMutationLifeCycles: commitBeforeMutationLifeCycles,
10208
10389
  commitResetTextContent: commitResetTextContent,
10209
10390
  commitPlacement: commitPlacement,
10210
10391
  commitDeletion: commitDeletion,
@@ -10247,12 +10428,19 @@ var ReactFiberHostContext = function (config, stack) {
10247
10428
  // Push current root instance onto the stack;
10248
10429
  // This allows us to reset root when portals are popped.
10249
10430
  push(rootInstanceStackCursor, nextRootInstance, fiber);
10250
-
10251
- var nextRootContext = getRootHostContext(nextRootInstance);
10252
-
10253
10431
  // Track the context and the Fiber that provided it.
10254
10432
  // This enables us to pop only Fibers that provide unique contexts.
10255
10433
  push(contextFiberStackCursor, fiber, fiber);
10434
+
10435
+ // Finally, we need to push the host context to the stack.
10436
+ // However, we can't just call getRootHostContext() and push it because
10437
+ // we'd have a different number of entries on the stack depending on
10438
+ // whether getRootHostContext() throws somewhere in renderer code or not.
10439
+ // So we push an empty value first. This lets us safely unwind on errors.
10440
+ push(contextStackCursor, NO_CONTEXT, fiber);
10441
+ var nextRootContext = getRootHostContext(nextRootInstance);
10442
+ // Now that we know this function doesn't throw, replace it.
10443
+ pop(contextStackCursor, fiber);
10256
10444
  push(contextStackCursor, nextRootContext, fiber);
10257
10445
  }
10258
10446
 
@@ -10855,7 +11043,7 @@ var ReactFiberNewContext = function (stack) {
10855
11043
  }
10856
11044
 
10857
11045
  function pushProvider(providerFiber) {
10858
- var context = providerFiber.type.context;
11046
+ var context = providerFiber.type._context;
10859
11047
 
10860
11048
  push(changedBitsCursor, context._changedBits, providerFiber);
10861
11049
  push(valueCursor, context._currentValue, providerFiber);
@@ -10865,7 +11053,7 @@ var ReactFiberNewContext = function (stack) {
10865
11053
  context._changedBits = providerFiber.stateNode;
10866
11054
 
10867
11055
  {
10868
- warning(context._currentRenderer === null || context._currentRenderer === rendererSigil, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.');
11056
+ !(context._currentRenderer === null || context._currentRenderer === rendererSigil) ? warning(false, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.') : void 0;
10869
11057
  context._currentRenderer = rendererSigil;
10870
11058
  }
10871
11059
  }
@@ -10878,7 +11066,7 @@ var ReactFiberNewContext = function (stack) {
10878
11066
  pop(valueCursor, providerFiber);
10879
11067
  pop(changedBitsCursor, providerFiber);
10880
11068
 
10881
- var context = providerFiber.type.context;
11069
+ var context = providerFiber.type._context;
10882
11070
  context._currentValue = currentValue;
10883
11071
  context._changedBits = changedBits;
10884
11072
  }
@@ -10989,11 +11177,13 @@ var warnAboutInvalidUpdates = void 0;
10989
11177
  var didWarnStateUpdateForUnmountedComponent = {};
10990
11178
 
10991
11179
  warnAboutUpdateOnUnmounted = function (fiber) {
11180
+ // We show the whole stack but dedupe on the top component's name because
11181
+ // the problematic code almost always lies inside that component.
10992
11182
  var componentName = getComponentName(fiber) || 'ReactClass';
10993
11183
  if (didWarnStateUpdateForUnmountedComponent[componentName]) {
10994
11184
  return;
10995
11185
  }
10996
- warning(false, 'Can only update a mounted or mounting ' + 'component. This usually means you called setState, replaceState, ' + 'or forceUpdate on an unmounted component. This is a no-op.\n\nPlease ' + 'check the code for the %s component.', componentName);
11186
+ warning(false, "Can't call setState (or forceUpdate) on an unmounted component. This " + 'is a no-op, but it indicates a memory leak in your application. To ' + 'fix, cancel all subscriptions and asynchronous tasks in the ' + 'componentWillUnmount method.%s', getStackAddendumByWorkInProgressFiber(fiber));
10997
11187
  didWarnStateUpdateForUnmountedComponent[componentName] = true;
10998
11188
  };
10999
11189
 
@@ -11042,6 +11232,7 @@ var ReactFiberScheduler = function (config) {
11042
11232
  unwindInterruptedWork = _ReactFiberUnwindWork.unwindInterruptedWork;
11043
11233
 
11044
11234
  var _ReactFiberCommitWork = ReactFiberCommitWork(config, onCommitPhaseError, scheduleWork, computeExpirationForFiber, markLegacyErrorBoundaryAsFailed, recalculateCurrentTime),
11235
+ commitBeforeMutationLifeCycles = _ReactFiberCommitWork.commitBeforeMutationLifeCycles,
11045
11236
  commitResetTextContent = _ReactFiberCommitWork.commitResetTextContent,
11046
11237
  commitPlacement = _ReactFiberCommitWork.commitPlacement,
11047
11238
  commitDeletion = _ReactFiberCommitWork.commitDeletion,
@@ -11093,11 +11284,16 @@ var ReactFiberScheduler = function (config) {
11093
11284
 
11094
11285
  var stashedWorkInProgressProperties = void 0;
11095
11286
  var replayUnitOfWork = void 0;
11287
+ var isReplayingFailedUnitOfWork = void 0;
11288
+ var originalReplayError = void 0;
11289
+ var rethrowOriginalError = void 0;
11096
11290
  if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
11097
11291
  stashedWorkInProgressProperties = null;
11098
- replayUnitOfWork = function (failedUnitOfWork, isAsync) {
11099
- // Retore the original state of the work-in-progress
11100
- _assign(failedUnitOfWork, stashedWorkInProgressProperties);
11292
+ isReplayingFailedUnitOfWork = false;
11293
+ originalReplayError = null;
11294
+ replayUnitOfWork = function (failedUnitOfWork, error, isAsync) {
11295
+ // Restore the original state of the work-in-progress
11296
+ assignFiberPropertiesInDEV(failedUnitOfWork, stashedWorkInProgressProperties);
11101
11297
  switch (failedUnitOfWork.tag) {
11102
11298
  case HostRoot:
11103
11299
  popHostContainer(failedUnitOfWork);
@@ -11117,14 +11313,22 @@ var ReactFiberScheduler = function (config) {
11117
11313
  break;
11118
11314
  }
11119
11315
  // Replay the begin phase.
11316
+ isReplayingFailedUnitOfWork = true;
11317
+ originalReplayError = error;
11120
11318
  invokeGuardedCallback$2(null, workLoop, null, isAsync);
11319
+ isReplayingFailedUnitOfWork = false;
11320
+ originalReplayError = null;
11121
11321
  if (hasCaughtError()) {
11122
11322
  clearCaughtError();
11123
11323
  } else {
11124
- // This should be unreachable because the render phase is
11125
- // idempotent
11324
+ // If the begin phase did not fail the second time, set this pointer
11325
+ // back to the original value.
11326
+ nextUnitOfWork = failedUnitOfWork;
11126
11327
  }
11127
11328
  };
11329
+ rethrowOriginalError = function () {
11330
+ throw originalReplayError;
11331
+ };
11128
11332
  }
11129
11333
 
11130
11334
  function resetStack() {
@@ -11156,6 +11360,7 @@ var ReactFiberScheduler = function (config) {
11156
11360
  recordEffect();
11157
11361
 
11158
11362
  var effectTag = nextEffect.effectTag;
11363
+
11159
11364
  if (effectTag & ContentReset) {
11160
11365
  commitResetTextContent(nextEffect);
11161
11366
  }
@@ -11217,6 +11422,22 @@ var ReactFiberScheduler = function (config) {
11217
11422
  }
11218
11423
  }
11219
11424
 
11425
+ function commitBeforeMutationLifecycles() {
11426
+ while (nextEffect !== null) {
11427
+ var effectTag = nextEffect.effectTag;
11428
+
11429
+ if (effectTag & Snapshot) {
11430
+ recordEffect();
11431
+ var current = nextEffect.alternate;
11432
+ commitBeforeMutationLifeCycles(current, nextEffect);
11433
+ }
11434
+
11435
+ // Don't cleanup effects yet;
11436
+ // This will be done by commitAllLifeCycles()
11437
+ nextEffect = nextEffect.nextEffect;
11438
+ }
11439
+ }
11440
+
11220
11441
  function commitAllLifeCycles(finishedRoot, currentTime, committedExpirationTime) {
11221
11442
  {
11222
11443
  ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
@@ -11302,16 +11523,14 @@ var ReactFiberScheduler = function (config) {
11302
11523
 
11303
11524
  prepareForCommit(root.containerInfo);
11304
11525
 
11305
- // Commit all the side-effects within a tree. We'll do this in two passes.
11306
- // The first pass performs all the host insertions, updates, deletions and
11307
- // ref unmounts.
11526
+ // Invoke instances of getSnapshotBeforeUpdate before mutation.
11308
11527
  nextEffect = firstEffect;
11309
- startCommitHostEffectsTimer();
11528
+ startCommitSnapshotEffectsTimer();
11310
11529
  while (nextEffect !== null) {
11311
11530
  var didError = false;
11312
11531
  var error = void 0;
11313
11532
  {
11314
- invokeGuardedCallback$2(null, commitAllHostEffects, null);
11533
+ invokeGuardedCallback$2(null, commitBeforeMutationLifecycles, null);
11315
11534
  if (hasCaughtError()) {
11316
11535
  didError = true;
11317
11536
  error = clearCaughtError();
@@ -11326,6 +11545,32 @@ var ReactFiberScheduler = function (config) {
11326
11545
  }
11327
11546
  }
11328
11547
  }
11548
+ stopCommitSnapshotEffectsTimer();
11549
+
11550
+ // Commit all the side-effects within a tree. We'll do this in two passes.
11551
+ // The first pass performs all the host insertions, updates, deletions and
11552
+ // ref unmounts.
11553
+ nextEffect = firstEffect;
11554
+ startCommitHostEffectsTimer();
11555
+ while (nextEffect !== null) {
11556
+ var _didError = false;
11557
+ var _error = void 0;
11558
+ {
11559
+ invokeGuardedCallback$2(null, commitAllHostEffects, null);
11560
+ if (hasCaughtError()) {
11561
+ _didError = true;
11562
+ _error = clearCaughtError();
11563
+ }
11564
+ }
11565
+ if (_didError) {
11566
+ !(nextEffect !== null) ? invariant(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0;
11567
+ onCommitPhaseError(nextEffect, _error);
11568
+ // Clean-up
11569
+ if (nextEffect !== null) {
11570
+ nextEffect = nextEffect.nextEffect;
11571
+ }
11572
+ }
11573
+ }
11329
11574
  stopCommitHostEffectsTimer();
11330
11575
 
11331
11576
  resetAfterCommit(root.containerInfo);
@@ -11343,18 +11588,18 @@ var ReactFiberScheduler = function (config) {
11343
11588
  nextEffect = firstEffect;
11344
11589
  startCommitLifeCyclesTimer();
11345
11590
  while (nextEffect !== null) {
11346
- var _didError = false;
11347
- var _error = void 0;
11591
+ var _didError2 = false;
11592
+ var _error2 = void 0;
11348
11593
  {
11349
11594
  invokeGuardedCallback$2(null, commitAllLifeCycles, null, root, currentTime, committedExpirationTime);
11350
11595
  if (hasCaughtError()) {
11351
- _didError = true;
11352
- _error = clearCaughtError();
11596
+ _didError2 = true;
11597
+ _error2 = clearCaughtError();
11353
11598
  }
11354
11599
  }
11355
- if (_didError) {
11600
+ if (_didError2) {
11356
11601
  !(nextEffect !== null) ? invariant(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0;
11357
- onCommitPhaseError(nextEffect, _error);
11602
+ onCommitPhaseError(nextEffect, _error2);
11358
11603
  if (nextEffect !== null) {
11359
11604
  nextEffect = nextEffect.nextEffect;
11360
11605
  }
@@ -11564,12 +11809,18 @@ var ReactFiberScheduler = function (config) {
11564
11809
  }
11565
11810
 
11566
11811
  if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
11567
- stashedWorkInProgressProperties = _assign({}, workInProgress);
11812
+ stashedWorkInProgressProperties = assignFiberPropertiesInDEV(stashedWorkInProgressProperties, workInProgress);
11568
11813
  }
11569
11814
  var next = beginWork(current, workInProgress, nextRenderExpirationTime);
11570
-
11571
11815
  {
11572
11816
  ReactDebugCurrentFiber.resetCurrentFiber();
11817
+ if (isReplayingFailedUnitOfWork) {
11818
+ // Currently replaying a failed unit of work. This should be unreachable,
11819
+ // because the render phase is meant to be idempotent, and it should
11820
+ // have thrown again. Since it didn't, rethrow the original error, so
11821
+ // React's internal stack is not misaligned.
11822
+ rethrowOriginalError();
11823
+ }
11573
11824
  }
11574
11825
  if (true && ReactFiberInstrumentation_1.debugTool) {
11575
11826
  ReactFiberInstrumentation_1.debugTool.onBeginWork(workInProgress);
@@ -11631,13 +11882,18 @@ var ReactFiberScheduler = function (config) {
11631
11882
 
11632
11883
  if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
11633
11884
  var failedUnitOfWork = nextUnitOfWork;
11634
- replayUnitOfWork(failedUnitOfWork, isAsync);
11885
+ replayUnitOfWork(failedUnitOfWork, thrownValue, isAsync);
11635
11886
  }
11636
11887
 
11637
11888
  var sourceFiber = nextUnitOfWork;
11638
11889
  var returnFiber = sourceFiber['return'];
11639
11890
  if (returnFiber === null) {
11640
- // This is a fatal error.
11891
+ // This is the root. The root could capture its own errors. However,
11892
+ // we don't know if it errors before or after we pushed the host
11893
+ // context. This information is needed to avoid a stack mismatch.
11894
+ // Because we're not sure, treat this as a fatal error. We could track
11895
+ // which phase it fails in, but doesn't seem worth it. At least
11896
+ // for now.
11641
11897
  didFatal = true;
11642
11898
  onUncaughtError(thrownValue);
11643
11899
  break;
@@ -11649,12 +11905,13 @@ var ReactFiberScheduler = function (config) {
11649
11905
  } while (true);
11650
11906
 
11651
11907
  // We're done performing work. Time to clean up.
11652
- stopWorkLoopTimer(interruptedBy);
11653
- interruptedBy = null;
11908
+ var didCompleteRoot = false;
11654
11909
  isWorking = false;
11655
11910
 
11656
11911
  // Yield back to main thread.
11657
11912
  if (didFatal) {
11913
+ stopWorkLoopTimer(interruptedBy, didCompleteRoot);
11914
+ interruptedBy = null;
11658
11915
  // There was a fatal error.
11659
11916
  {
11660
11917
  stack.resetStackAfterFatalErrorInDev();
@@ -11663,15 +11920,22 @@ var ReactFiberScheduler = function (config) {
11663
11920
  } else if (nextUnitOfWork === null) {
11664
11921
  // We reached the root.
11665
11922
  if (isRootReadyForCommit) {
11923
+ didCompleteRoot = true;
11924
+ stopWorkLoopTimer(interruptedBy, didCompleteRoot);
11925
+ interruptedBy = null;
11666
11926
  // The root successfully completed. It's ready for commit.
11667
11927
  root.pendingCommitExpirationTime = expirationTime;
11668
11928
  var finishedWork = root.current.alternate;
11669
11929
  return finishedWork;
11670
11930
  } else {
11671
11931
  // The root did not complete.
11932
+ stopWorkLoopTimer(interruptedBy, didCompleteRoot);
11933
+ interruptedBy = null;
11672
11934
  invariant(false, 'Expired work should have completed. This error is likely caused by a bug in React. Please file an issue.');
11673
11935
  }
11674
11936
  } else {
11937
+ stopWorkLoopTimer(interruptedBy, didCompleteRoot);
11938
+ interruptedBy = null;
11675
11939
  // There's more work to do, but we ran out of time. Yield back to
11676
11940
  // the renderer.
11677
11941
  return null;
@@ -11739,8 +12003,19 @@ var ReactFiberScheduler = function (config) {
11739
12003
  }
11740
12004
 
11741
12005
  function computeInteractiveExpiration(currentTime) {
11742
- // Should complete within ~500ms. 600ms max.
11743
- var expirationMs = 500;
12006
+ var expirationMs = void 0;
12007
+ // We intentionally set a higher expiration time for interactive updates in
12008
+ // dev than in production.
12009
+ // If the main thread is being blocked so long that you hit the expiration,
12010
+ // it's a problem that could be solved with better scheduling.
12011
+ // People will be more likely to notice this and fix it with the long
12012
+ // expiration time in development.
12013
+ // In production we opt for better UX at the risk of masking scheduling
12014
+ // problems, by expiring fast.
12015
+ {
12016
+ // Should complete within ~500ms. 600ms max.
12017
+ expirationMs = 500;
12018
+ }
11744
12019
  var bucketSizeMs = 100;
11745
12020
  return computeExpirationBucket(currentTime, expirationMs, bucketSizeMs);
11746
12021
  }
@@ -11837,7 +12112,13 @@ var ReactFiberScheduler = function (config) {
11837
12112
  interruptedBy = fiber;
11838
12113
  resetStack();
11839
12114
  }
11840
- if (nextRoot !== root || !isWorking) {
12115
+ if (
12116
+ // If we're in the render phase, we don't need to schedule this root
12117
+ // for an update, because we'll do it before we exit...
12118
+ !isWorking || isCommitting ||
12119
+ // ...unless this is a different root than the one we're rendering.
12120
+ nextRoot !== root) {
12121
+ // Add this root to the root schedule.
11841
12122
  requestWork(root, expirationTime);
11842
12123
  }
11843
12124
  if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
@@ -12075,7 +12356,8 @@ var ReactFiberScheduler = function (config) {
12075
12356
 
12076
12357
  if (enableUserTimingAPI && deadline !== null) {
12077
12358
  var didExpire = nextFlushedExpirationTime < recalculateCurrentTime();
12078
- stopRequestCallbackTimer(didExpire);
12359
+ var timeout = expirationTimeToMs(nextFlushedExpirationTime);
12360
+ stopRequestCallbackTimer(didExpire, timeout);
12079
12361
  }
12080
12362
 
12081
12363
  if (isAsync) {
@@ -12115,7 +12397,11 @@ var ReactFiberScheduler = function (config) {
12115
12397
  // Perform work on root as if the given expiration time is the current time.
12116
12398
  // This has the effect of synchronously flushing all work up to and
12117
12399
  // including the given time.
12400
+ nextFlushedRoot = root;
12401
+ nextFlushedExpirationTime = expirationTime;
12118
12402
  performWorkOnRoot(root, expirationTime, false);
12403
+ // Flush any sync work that was scheduled by lifecycles
12404
+ performSyncWork();
12119
12405
  finishRendering();
12120
12406
  }
12121
12407
 
@@ -12408,7 +12694,7 @@ var ReactFiberReconciler$1 = function (config) {
12408
12694
 
12409
12695
  callback = callback === undefined ? null : callback;
12410
12696
  {
12411
- warning(callback === null || typeof callback === 'function', 'render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback);
12697
+ !(callback === null || typeof callback === 'function') ? warning(false, 'render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback) : void 0;
12412
12698
  }
12413
12699
 
12414
12700
  var update = {
@@ -12452,7 +12738,15 @@ var ReactFiberReconciler$1 = function (config) {
12452
12738
  return scheduleRootUpdate(current, element, currentTime, expirationTime, callback);
12453
12739
  }
12454
12740
 
12455
- function findHostInstance(fiber) {
12741
+ function findHostInstance(component) {
12742
+ var fiber = get(component);
12743
+ if (fiber === undefined) {
12744
+ if (typeof component.render === 'function') {
12745
+ invariant(false, 'Unable to find node on an unmounted component.');
12746
+ } else {
12747
+ invariant(false, 'Argument appears to not be a ReactComponent. Keys: %s', Object.keys(component));
12748
+ }
12749
+ }
12456
12750
  var hostFiber = findCurrentHostFiber(fiber);
12457
12751
  if (hostFiber === null) {
12458
12752
  return null;
@@ -12526,7 +12820,11 @@ var ReactFiberReconciler$1 = function (config) {
12526
12820
 
12527
12821
  return injectInternals(_assign({}, devToolsConfig, {
12528
12822
  findHostInstanceByFiber: function (fiber) {
12529
- return findHostInstance(fiber);
12823
+ var hostFiber = findCurrentHostFiber(fiber);
12824
+ if (hostFiber === null) {
12825
+ return null;
12826
+ }
12827
+ return hostFiber.stateNode;
12530
12828
  },
12531
12829
  findFiberByHostInstance: function (instance) {
12532
12830
  if (!findFiberByHostInstance) {
@@ -12571,7 +12869,7 @@ implementation) {
12571
12869
 
12572
12870
  // TODO: this is special because it gets imported during build.
12573
12871
 
12574
- var ReactVersion = '16.3.0-alpha.3';
12872
+ var ReactVersion = '16.3.2';
12575
12873
 
12576
12874
  // a requestAnimationFrame, storing the time for the start of the frame, then
12577
12875
  // scheduling a postMessage which gets scheduled after paint. Within the
@@ -12609,7 +12907,9 @@ if (!ExecutionEnvironment.canUseDOM) {
12609
12907
  frameCallback({
12610
12908
  timeRemaining: function () {
12611
12909
  return Infinity;
12612
- }
12910
+ },
12911
+
12912
+ didTimeout: false
12613
12913
  });
12614
12914
  });
12615
12915
  };
@@ -13487,7 +13787,7 @@ function assertValidProps(tag, props, getStack) {
13487
13787
  !(typeof props.dangerouslySetInnerHTML === 'object' && HTML$1 in props.dangerouslySetInnerHTML) ? invariant(false, '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information.') : void 0;
13488
13788
  }
13489
13789
  {
13490
- warning(props.suppressContentEditableWarning || !props.contentEditable || props.children == null, 'A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.%s', getStack());
13790
+ !(props.suppressContentEditableWarning || !props.contentEditable || props.children == null) ? warning(false, 'A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.%s', getStack()) : void 0;
13491
13791
  }
13492
13792
  !(props.style == null || typeof props.style === 'object') ? invariant(false, 'The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + \'em\'}} when using JSX.%s', getStack()) : void 0;
13493
13793
  }
@@ -14550,7 +14850,7 @@ function createElement$1(type, props, rootContainerElement, parentNamespace) {
14550
14850
  isCustomComponentTag = isCustomComponent(type, props);
14551
14851
  // Should this check be gated by parent namespace? Not sure we want to
14552
14852
  // allow <SVG> or <mATH>.
14553
- warning(isCustomComponentTag || type === type.toLowerCase(), '<%s /> is using uppercase HTML. Always use lowercase HTML tags ' + 'in React.', type);
14853
+ !(isCustomComponentTag || type === type.toLowerCase()) ? warning(false, '<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', type) : void 0;
14554
14854
  }
14555
14855
 
14556
14856
  if (type === 'script') {
@@ -15503,7 +15803,7 @@ var validateDOMNesting = emptyFunction;
15503
15803
  var parentTag = parentInfo && parentInfo.tag;
15504
15804
 
15505
15805
  if (childText != null) {
15506
- warning(childTag == null, 'validateDOMNesting: when childText is passed, childTag should be null');
15806
+ !(childTag == null) ? warning(false, 'validateDOMNesting: when childText is passed, childTag should be null') : void 0;
15507
15807
  childTag = '#text';
15508
15808
  }
15509
15809
 
@@ -15589,7 +15889,7 @@ var didWarnAboutUnstableCreatePortal = false;
15589
15889
  if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) {
15590
15890
  var hostInstance = DOMRenderer.findHostInstanceWithNoPortals(container._reactRootContainer._internalRoot.current);
15591
15891
  if (hostInstance) {
15592
- warning(hostInstance.parentNode === container, 'render(...): It looks like the React-rendered content of this ' + 'container was removed without using React. This is not ' + 'supported and will cause errors. Instead, call ' + 'ReactDOM.unmountComponentAtNode to empty a container.');
15892
+ !(hostInstance.parentNode === container) ? warning(false, 'render(...): It looks like the React-rendered content of this ' + 'container was removed without using React. This is not ' + 'supported and will cause errors. Instead, call ' + 'ReactDOM.unmountComponentAtNode to empty a container.') : void 0;
15593
15893
  }
15594
15894
  }
15595
15895
 
@@ -15597,13 +15897,13 @@ var didWarnAboutUnstableCreatePortal = false;
15597
15897
  var rootEl = getReactRootElementInContainer(container);
15598
15898
  var hasNonRootReactChild = !!(rootEl && getInstanceFromNode$1(rootEl));
15599
15899
 
15600
- warning(!hasNonRootReactChild || isRootRenderedBySomeReact, 'render(...): Replacing React-rendered children with a new root ' + 'component. If you intended to update the children of this node, ' + 'you should instead have the existing children update their state ' + 'and render the new components instead of calling ReactDOM.render.');
15900
+ !(!hasNonRootReactChild || isRootRenderedBySomeReact) ? warning(false, 'render(...): Replacing React-rendered children with a new root ' + 'component. If you intended to update the children of this node, ' + 'you should instead have the existing children update their state ' + 'and render the new components instead of calling ReactDOM.render.') : void 0;
15601
15901
 
15602
- warning(container.nodeType !== ELEMENT_NODE || !container.tagName || container.tagName.toUpperCase() !== 'BODY', 'render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.');
15902
+ !(container.nodeType !== ELEMENT_NODE || !container.tagName || container.tagName.toUpperCase() !== 'BODY') ? warning(false, 'render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.') : void 0;
15603
15903
  };
15604
15904
 
15605
15905
  warnOnInvalidCallback = function (callback, callerName) {
15606
- warning(callback === null || typeof callback === 'function', '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
15906
+ !(callback === null || typeof callback === 'function') ? warning(false, '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback) : void 0;
15607
15907
  };
15608
15908
  }
15609
15909
 
@@ -16222,7 +16522,7 @@ var ReactDOM = {
16222
16522
  var owner = ReactCurrentOwner.current;
16223
16523
  if (owner !== null && owner.stateNode !== null) {
16224
16524
  var warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender;
16225
- warning(warnedAboutRefsInRender, '%s is accessing findDOMNode inside its render(). ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(owner) || 'A component');
16525
+ !warnedAboutRefsInRender ? warning(false, '%s is accessing findDOMNode inside its render(). ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(owner) || 'A component') : void 0;
16226
16526
  owner.stateNode._warnedAboutRefsInRender = true;
16227
16527
  }
16228
16528
  }
@@ -16233,16 +16533,7 @@ var ReactDOM = {
16233
16533
  return componentOrElement;
16234
16534
  }
16235
16535
 
16236
- var inst = get(componentOrElement);
16237
- if (inst) {
16238
- return DOMRenderer.findHostInstance(inst);
16239
- }
16240
-
16241
- if (typeof componentOrElement.render === 'function') {
16242
- invariant(false, 'Unable to find node on an unmounted component.');
16243
- } else {
16244
- invariant(false, 'Element appears to be neither ReactComponent nor DOMNode. Keys: %s', Object.keys(componentOrElement));
16245
- }
16536
+ return DOMRenderer.findHostInstance(componentOrElement);
16246
16537
  },
16247
16538
  hydrate: function (element, container, callback) {
16248
16539
  // TODO: throw or warn if we couldn't hydrate?
@@ -16262,7 +16553,7 @@ var ReactDOM = {
16262
16553
  {
16263
16554
  var rootEl = getReactRootElementInContainer(container);
16264
16555
  var renderedByDifferentReact = rootEl && !getInstanceFromNode$1(rootEl);
16265
- warning(!renderedByDifferentReact, "unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by another copy of React.');
16556
+ !!renderedByDifferentReact ? warning(false, "unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by another copy of React.') : void 0;
16266
16557
  }
16267
16558
 
16268
16559
  // Unmount should not be batched.
@@ -16282,7 +16573,7 @@ var ReactDOM = {
16282
16573
  // Check if the container itself is a React root node.
16283
16574
  var isContainerReactRoot = container.nodeType === 1 && isValidContainer(container.parentNode) && !!container.parentNode._reactRootContainer;
16284
16575
 
16285
- warning(!hasNonRootReactChild, "unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by React and is not a top-level container. %s', isContainerReactRoot ? 'You may have accidentally passed in a React root node instead ' + 'of its container.' : 'Instead, have the parent component update its state and ' + 'rerender in order to remove this component.');
16576
+ !!hasNonRootReactChild ? warning(false, "unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by React and is not a top-level container. %s', isContainerReactRoot ? 'You may have accidentally passed in a React root node instead ' + 'of its container.' : 'Instead, have the parent component update its state and ' + 'rerender in order to remove this component.') : void 0;
16286
16577
  }
16287
16578
 
16288
16579
  return false;
@@ -16321,12 +16612,10 @@ var ReactDOM = {
16321
16612
  }
16322
16613
  };
16323
16614
 
16324
- if (enableCreateRoot) {
16325
- ReactDOM.createRoot = function createRoot(container, options) {
16326
- var hydrate = options != null && options.hydrate === true;
16327
- return new ReactRoot(container, true, hydrate);
16328
- };
16329
- }
16615
+ ReactDOM.unstable_createRoot = function createRoot(container, options) {
16616
+ var hydrate = options != null && options.hydrate === true;
16617
+ return new ReactRoot(container, true, hydrate);
16618
+ };
16330
16619
 
16331
16620
  var foundDevTools = DOMRenderer.injectIntoDevTools({
16332
16621
  findFiberByHostInstance: getClosestInstanceFromNode,