react 16.6.0-alpha.8af6728 → 16.6.3

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.6.0-alpha.8af6728
1
+ /** @license React v16.6.1
2
2
  * react.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -20,7 +20,7 @@ var checkPropTypes = require('prop-types/checkPropTypes');
20
20
 
21
21
  // TODO: this is special because it gets imported during build.
22
22
 
23
- var ReactVersion = '16.6.0-alpha.8af6728';
23
+ var ReactVersion = '16.6.3';
24
24
 
25
25
  // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
26
26
  // nor polyfill, then a plain number is used for performance.
@@ -33,10 +33,12 @@ var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeac
33
33
  var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
34
34
  var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
35
35
  var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
36
+
36
37
  var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
37
38
  var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
38
39
  var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
39
- var REACT_PURE_TYPE = hasSymbol ? Symbol.for('react.pure') : 0xead3;
40
+ var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
41
+ var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
40
42
 
41
43
  var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
42
44
  var FAUX_ITERATOR_SYMBOL = '@@iterator';
@@ -52,6 +54,43 @@ function getIteratorFn(maybeIterable) {
52
54
  return null;
53
55
  }
54
56
 
57
+ var enableHooks = false;
58
+ // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
59
+
60
+
61
+ // In some cases, StrictMode should also double-render lifecycles.
62
+ // This can be confusing for tests though,
63
+ // And it can be bad for performance in production.
64
+ // This feature flag can be used to control the behavior:
65
+
66
+
67
+ // To preserve the "Pause on caught exceptions" behavior of the debugger, we
68
+ // replay the begin phase of a failed component inside invokeGuardedCallback.
69
+
70
+
71
+ // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
72
+
73
+
74
+ // Gather advanced timing metrics for Profiler subtrees.
75
+
76
+
77
+ // Trace which interactions trigger each commit.
78
+
79
+
80
+ // Only used in www builds.
81
+
82
+
83
+ // Only used in www builds.
84
+
85
+
86
+ // React Fire: prevent the value and checked attributes from syncing
87
+ // with their related DOM properties
88
+
89
+
90
+ // These APIs will no longer be "unstable" in the upcoming 16.7 release,
91
+ // Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
92
+ var enableStableConcurrentModeAPIs = false;
93
+
55
94
  /**
56
95
  * Use invariant() to assert state which your program assumes to be true.
57
96
  *
@@ -176,63 +215,24 @@ var warningWithoutStack = function () {};
176
215
  return;
177
216
  }
178
217
  if (typeof console !== 'undefined') {
179
- var _args$map = args.map(function (item) {
218
+ var argsWithFormat = args.map(function (item) {
180
219
  return '' + item;
181
- }),
182
- a = _args$map[0],
183
- b = _args$map[1],
184
- c = _args$map[2],
185
- d = _args$map[3],
186
- e = _args$map[4],
187
- f = _args$map[5],
188
- g = _args$map[6],
189
- h = _args$map[7];
190
-
191
- var message = 'Warning: ' + format;
192
-
193
- // We intentionally don't use spread (or .apply) because it breaks IE9:
194
- // https://github.com/facebook/react/issues/13610
195
- switch (args.length) {
196
- case 0:
197
- console.error(message);
198
- break;
199
- case 1:
200
- console.error(message, a);
201
- break;
202
- case 2:
203
- console.error(message, a, b);
204
- break;
205
- case 3:
206
- console.error(message, a, b, c);
207
- break;
208
- case 4:
209
- console.error(message, a, b, c, d);
210
- break;
211
- case 5:
212
- console.error(message, a, b, c, d, e);
213
- break;
214
- case 6:
215
- console.error(message, a, b, c, d, e, f);
216
- break;
217
- case 7:
218
- console.error(message, a, b, c, d, e, f, g);
219
- break;
220
- case 8:
221
- console.error(message, a, b, c, d, e, f, g, h);
222
- break;
223
- default:
224
- throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
225
- }
220
+ });
221
+ argsWithFormat.unshift('Warning: ' + format);
222
+
223
+ // We intentionally don't use spread (or .apply) directly because it
224
+ // breaks IE9: https://github.com/facebook/react/issues/13610
225
+ Function.prototype.apply.call(console.error, console, argsWithFormat);
226
226
  }
227
227
  try {
228
228
  // --- Welcome to debugging React ---
229
229
  // This error was thrown as a convenience so that you can use this stack
230
230
  // to find the callsite that caused this warning to fire.
231
231
  var argIndex = 0;
232
- var _message = 'Warning: ' + format.replace(/%s/g, function () {
232
+ var message = 'Warning: ' + format.replace(/%s/g, function () {
233
233
  return args[argIndex++];
234
234
  });
235
- throw new Error(_message);
235
+ throw new Error(message);
236
236
  } catch (x) {}
237
237
  };
238
238
  }
@@ -492,10 +492,13 @@ var describeComponentFrame = function (name, source, ownerName) {
492
492
  var Resolved = 1;
493
493
 
494
494
 
495
+ function refineResolvedLazyComponent(lazyComponent) {
496
+ return lazyComponent._status === Resolved ? lazyComponent._result : null;
497
+ }
495
498
 
496
-
497
- function refineResolvedThenable(thenable) {
498
- return thenable._reactStatus === Resolved ? thenable._reactResult : null;
499
+ function getWrappedName(outerType, innerType, wrapperName) {
500
+ var functionName = innerType.displayName || innerType.name || '';
501
+ return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
499
502
  }
500
503
 
501
504
  function getComponentName(type) {
@@ -535,16 +538,17 @@ function getComponentName(type) {
535
538
  case REACT_PROVIDER_TYPE:
536
539
  return 'Context.Provider';
537
540
  case REACT_FORWARD_REF_TYPE:
538
- var renderFn = type.render;
539
- var functionName = renderFn.displayName || renderFn.name || '';
540
- return type.displayName || (functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef');
541
- }
542
- if (typeof type.then === 'function') {
543
- var thenable = type;
544
- var resolvedThenable = refineResolvedThenable(thenable);
545
- if (resolvedThenable) {
546
- return getComponentName(resolvedThenable);
547
- }
541
+ return getWrappedName(type, type.render, 'ForwardRef');
542
+ case REACT_MEMO_TYPE:
543
+ return getComponentName(type.type);
544
+ case REACT_LAZY_TYPE:
545
+ {
546
+ var thenable = type;
547
+ var resolvedThenable = refineResolvedLazyComponent(thenable);
548
+ if (resolvedThenable) {
549
+ return getComponentName(resolvedThenable);
550
+ }
551
+ }
548
552
  }
549
553
  }
550
554
  return null;
@@ -1259,12 +1263,6 @@ function onlyChild(children) {
1259
1263
  return children;
1260
1264
  }
1261
1265
 
1262
- function readContext(context, observedBits) {
1263
- var dispatcher = ReactCurrentOwner.currentDispatcher;
1264
- !(dispatcher !== null) ? invariant(false, 'Context.unstable_read(): Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps.') : void 0;
1265
- return dispatcher.readContext(context, observedBits);
1266
- }
1267
-
1268
1266
  function createContext(defaultValue, calculateChangedBits) {
1269
1267
  if (calculateChangedBits === undefined) {
1270
1268
  calculateChangedBits = null;
@@ -1284,18 +1282,82 @@ function createContext(defaultValue, calculateChangedBits) {
1284
1282
  // Secondary renderers store their context values on separate fields.
1285
1283
  _currentValue: defaultValue,
1286
1284
  _currentValue2: defaultValue,
1285
+ // Used to track how many concurrent renderers this context currently
1286
+ // supports within in a single renderer. Such as parallel server rendering.
1287
+ _threadCount: 0,
1287
1288
  // These are circular
1288
1289
  Provider: null,
1289
- Consumer: null,
1290
- unstable_read: null
1290
+ Consumer: null
1291
1291
  };
1292
1292
 
1293
1293
  context.Provider = {
1294
1294
  $$typeof: REACT_PROVIDER_TYPE,
1295
1295
  _context: context
1296
1296
  };
1297
- context.Consumer = context;
1298
- context.unstable_read = readContext.bind(null, context);
1297
+
1298
+ var hasWarnedAboutUsingNestedContextConsumers = false;
1299
+ var hasWarnedAboutUsingConsumerProvider = false;
1300
+
1301
+ {
1302
+ // A separate object, but proxies back to the original context object for
1303
+ // backwards compatibility. It has a different $$typeof, so we can properly
1304
+ // warn for the incorrect usage of Context as a Consumer.
1305
+ var Consumer = {
1306
+ $$typeof: REACT_CONTEXT_TYPE,
1307
+ _context: context,
1308
+ _calculateChangedBits: context._calculateChangedBits
1309
+ };
1310
+ // $FlowFixMe: Flow complains about not setting a value, which is intentional here
1311
+ Object.defineProperties(Consumer, {
1312
+ Provider: {
1313
+ get: function () {
1314
+ if (!hasWarnedAboutUsingConsumerProvider) {
1315
+ hasWarnedAboutUsingConsumerProvider = true;
1316
+ warning$1(false, 'Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?');
1317
+ }
1318
+ return context.Provider;
1319
+ },
1320
+ set: function (_Provider) {
1321
+ context.Provider = _Provider;
1322
+ }
1323
+ },
1324
+ _currentValue: {
1325
+ get: function () {
1326
+ return context._currentValue;
1327
+ },
1328
+ set: function (_currentValue) {
1329
+ context._currentValue = _currentValue;
1330
+ }
1331
+ },
1332
+ _currentValue2: {
1333
+ get: function () {
1334
+ return context._currentValue2;
1335
+ },
1336
+ set: function (_currentValue2) {
1337
+ context._currentValue2 = _currentValue2;
1338
+ }
1339
+ },
1340
+ _threadCount: {
1341
+ get: function () {
1342
+ return context._threadCount;
1343
+ },
1344
+ set: function (_threadCount) {
1345
+ context._threadCount = _threadCount;
1346
+ }
1347
+ },
1348
+ Consumer: {
1349
+ get: function () {
1350
+ if (!hasWarnedAboutUsingNestedContextConsumers) {
1351
+ hasWarnedAboutUsingNestedContextConsumers = true;
1352
+ warning$1(false, 'Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
1353
+ }
1354
+ return context.Consumer;
1355
+ }
1356
+ }
1357
+ });
1358
+ // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
1359
+ context.Consumer = Consumer;
1360
+ }
1299
1361
 
1300
1362
  {
1301
1363
  context._currentRenderer = null;
@@ -1306,26 +1368,20 @@ function createContext(defaultValue, calculateChangedBits) {
1306
1368
  }
1307
1369
 
1308
1370
  function lazy(ctor) {
1309
- var thenable = null;
1310
1371
  return {
1311
- then: function (resolve, reject) {
1312
- if (thenable === null) {
1313
- // Lazily create thenable by wrapping in an extra thenable.
1314
- thenable = ctor();
1315
- ctor = null;
1316
- }
1317
- return thenable.then(resolve, reject);
1318
- },
1319
-
1372
+ $$typeof: REACT_LAZY_TYPE,
1373
+ _ctor: ctor,
1320
1374
  // React uses these fields to store the result.
1321
- _reactStatus: -1,
1322
- _reactResult: null
1375
+ _status: -1,
1376
+ _result: null
1323
1377
  };
1324
1378
  }
1325
1379
 
1326
1380
  function forwardRef(render) {
1327
1381
  {
1328
- if (typeof render !== 'function') {
1382
+ if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
1383
+ warningWithoutStack$1(false, 'forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
1384
+ } else if (typeof render !== 'function') {
1329
1385
  warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
1330
1386
  } else {
1331
1387
  !(
@@ -1344,28 +1400,92 @@ function forwardRef(render) {
1344
1400
  };
1345
1401
  }
1346
1402
 
1347
- function pure(render, compare) {
1403
+ function isValidElementType(type) {
1404
+ return typeof type === 'string' || typeof type === 'function' ||
1405
+ // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
1406
+ type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
1407
+ }
1408
+
1409
+ function memo(type, compare) {
1348
1410
  {
1349
- if (typeof render !== 'function') {
1350
- warningWithoutStack$1(false, 'pure: The first argument must be a function component. Instead ' + 'received: %s', render === null ? 'null' : typeof render);
1351
- } else {
1352
- var prototype = render.prototype;
1353
- if (prototype && prototype.isReactComponent) {
1354
- warningWithoutStack$1(false, 'pure: The first argument must be a function component. Classes ' + 'are not supported. Use React.PureComponent instead.');
1355
- }
1411
+ if (!isValidElementType(type)) {
1412
+ warningWithoutStack$1(false, 'memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
1356
1413
  }
1357
1414
  }
1358
1415
  return {
1359
- $$typeof: REACT_PURE_TYPE,
1360
- render: render,
1416
+ $$typeof: REACT_MEMO_TYPE,
1417
+ type: type,
1361
1418
  compare: compare === undefined ? null : compare
1362
1419
  };
1363
1420
  }
1364
1421
 
1365
- function isValidElementType(type) {
1366
- return typeof type === 'string' || typeof type === 'function' ||
1367
- // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
1368
- type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (typeof type.then === 'function' || type.$$typeof === REACT_PURE_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
1422
+ function resolveDispatcher() {
1423
+ var dispatcher = ReactCurrentOwner.currentDispatcher;
1424
+ !(dispatcher !== null) ? invariant(false, 'Hooks can only be called inside the body of a function component.') : void 0;
1425
+ return dispatcher;
1426
+ }
1427
+
1428
+ function useContext(Context, observedBits) {
1429
+ var dispatcher = resolveDispatcher();
1430
+ {
1431
+ // TODO: add a more generic warning for invalid values.
1432
+ if (Context._context !== undefined) {
1433
+ var realContext = Context._context;
1434
+ // Don't deduplicate because this legitimately causes bugs
1435
+ // and nobody should be using this in existing code.
1436
+ if (realContext.Consumer === Context) {
1437
+ warning$1(false, 'Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?');
1438
+ } else if (realContext.Provider === Context) {
1439
+ warning$1(false, 'Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
1440
+ }
1441
+ }
1442
+ }
1443
+ return dispatcher.useContext(Context, observedBits);
1444
+ }
1445
+
1446
+ function useState(initialState) {
1447
+ var dispatcher = resolveDispatcher();
1448
+ return dispatcher.useState(initialState);
1449
+ }
1450
+
1451
+ function useReducer(reducer, initialState, initialAction) {
1452
+ var dispatcher = resolveDispatcher();
1453
+ return dispatcher.useReducer(reducer, initialState, initialAction);
1454
+ }
1455
+
1456
+ function useRef(initialValue) {
1457
+ var dispatcher = resolveDispatcher();
1458
+ return dispatcher.useRef(initialValue);
1459
+ }
1460
+
1461
+ function useEffect(create, inputs) {
1462
+ var dispatcher = resolveDispatcher();
1463
+ return dispatcher.useEffect(create, inputs);
1464
+ }
1465
+
1466
+ function useMutationEffect(create, inputs) {
1467
+ var dispatcher = resolveDispatcher();
1468
+ return dispatcher.useMutationEffect(create, inputs);
1469
+ }
1470
+
1471
+ function useLayoutEffect(create, inputs) {
1472
+ var dispatcher = resolveDispatcher();
1473
+ return dispatcher.useLayoutEffect(create, inputs);
1474
+ }
1475
+
1476
+ function useCallback(callback, inputs) {
1477
+ var dispatcher = resolveDispatcher();
1478
+ return dispatcher.useCallback(callback, inputs);
1479
+ }
1480
+
1481
+ function useMemo(create, inputs) {
1482
+ var dispatcher = resolveDispatcher();
1483
+ return dispatcher.useMemo(create, inputs);
1484
+ }
1485
+
1486
+ function useImperativeMethods(ref, create, inputs) {
1487
+ var dispatcher = resolveDispatcher();
1488
+ return dispatcher.useImperativeMethods(ref, create, inputs);
1369
1489
  }
1370
1490
 
1371
1491
  /**
@@ -1666,13 +1786,11 @@ var React = {
1666
1786
  createContext: createContext,
1667
1787
  forwardRef: forwardRef,
1668
1788
  lazy: lazy,
1669
- pure: pure,
1789
+ memo: memo,
1670
1790
 
1671
1791
  Fragment: REACT_FRAGMENT_TYPE,
1672
1792
  StrictMode: REACT_STRICT_MODE_TYPE,
1673
- unstable_ConcurrentMode: REACT_CONCURRENT_MODE_TYPE,
1674
- unstable_Suspense: REACT_SUSPENSE_TYPE,
1675
- unstable_Profiler: REACT_PROFILER_TYPE,
1793
+ Suspense: REACT_SUSPENSE_TYPE,
1676
1794
 
1677
1795
  createElement: createElementWithValidation,
1678
1796
  cloneElement: cloneElementWithValidation,
@@ -1684,6 +1802,27 @@ var React = {
1684
1802
  __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals
1685
1803
  };
1686
1804
 
1805
+ if (enableStableConcurrentModeAPIs) {
1806
+ React.ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
1807
+ React.Profiler = REACT_PROFILER_TYPE;
1808
+ } else {
1809
+ React.unstable_ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
1810
+ React.unstable_Profiler = REACT_PROFILER_TYPE;
1811
+ }
1812
+
1813
+ if (enableHooks) {
1814
+ React.useCallback = useCallback;
1815
+ React.useContext = useContext;
1816
+ React.useEffect = useEffect;
1817
+ React.useImperativeMethods = useImperativeMethods;
1818
+ React.useLayoutEffect = useLayoutEffect;
1819
+ React.useMemo = useMemo;
1820
+ React.useMutationEffect = useMutationEffect;
1821
+ React.useReducer = useReducer;
1822
+ React.useRef = useRef;
1823
+ React.useState = useState;
1824
+ }
1825
+
1687
1826
 
1688
1827
 
1689
1828
  var React$2 = Object.freeze({