react 16.6.0-alpha.f47a958 → 16.6.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.6.0-alpha.f47a958
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.f47a958';
23
+ var ReactVersion = '16.6.2';
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
- var REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for('react.placeholder') : 0xead1;
39
- var REACT_PURE_TYPE = hasSymbol ? Symbol.for('react.pure') : 0xead3;
39
+ var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
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,11 +54,7 @@ function getIteratorFn(maybeIterable) {
52
54
  return null;
53
55
  }
54
56
 
55
- // Exports ReactDOM.createRoot
56
-
57
-
58
- // Suspense
59
- var enableSuspense = false;
57
+ var enableHooks = false;
60
58
  // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
61
59
 
62
60
 
@@ -88,6 +86,11 @@ var enableSuspense = false;
88
86
  // React Fire: prevent the value and checked attributes from syncing
89
87
  // with their related DOM properties
90
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
+
91
94
  /**
92
95
  * Use invariant() to assert state which your program assumes to be true.
93
96
  *
@@ -212,63 +215,24 @@ var warningWithoutStack = function () {};
212
215
  return;
213
216
  }
214
217
  if (typeof console !== 'undefined') {
215
- var _args$map = args.map(function (item) {
218
+ var argsWithFormat = args.map(function (item) {
216
219
  return '' + item;
217
- }),
218
- a = _args$map[0],
219
- b = _args$map[1],
220
- c = _args$map[2],
221
- d = _args$map[3],
222
- e = _args$map[4],
223
- f = _args$map[5],
224
- g = _args$map[6],
225
- h = _args$map[7];
226
-
227
- var message = 'Warning: ' + format;
228
-
229
- // We intentionally don't use spread (or .apply) because it breaks IE9:
230
- // https://github.com/facebook/react/issues/13610
231
- switch (args.length) {
232
- case 0:
233
- console.error(message);
234
- break;
235
- case 1:
236
- console.error(message, a);
237
- break;
238
- case 2:
239
- console.error(message, a, b);
240
- break;
241
- case 3:
242
- console.error(message, a, b, c);
243
- break;
244
- case 4:
245
- console.error(message, a, b, c, d);
246
- break;
247
- case 5:
248
- console.error(message, a, b, c, d, e);
249
- break;
250
- case 6:
251
- console.error(message, a, b, c, d, e, f);
252
- break;
253
- case 7:
254
- console.error(message, a, b, c, d, e, f, g);
255
- break;
256
- case 8:
257
- console.error(message, a, b, c, d, e, f, g, h);
258
- break;
259
- default:
260
- throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
261
- }
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);
262
226
  }
263
227
  try {
264
228
  // --- Welcome to debugging React ---
265
229
  // This error was thrown as a convenience so that you can use this stack
266
230
  // to find the callsite that caused this warning to fire.
267
231
  var argIndex = 0;
268
- var _message = 'Warning: ' + format.replace(/%s/g, function () {
232
+ var message = 'Warning: ' + format.replace(/%s/g, function () {
269
233
  return args[argIndex++];
270
234
  });
271
- throw new Error(_message);
235
+ throw new Error(message);
272
236
  } catch (x) {}
273
237
  };
274
238
  }
@@ -528,10 +492,13 @@ var describeComponentFrame = function (name, source, ownerName) {
528
492
  var Resolved = 1;
529
493
 
530
494
 
495
+ function refineResolvedLazyComponent(lazyComponent) {
496
+ return lazyComponent._status === Resolved ? lazyComponent._result : null;
497
+ }
531
498
 
532
-
533
- function refineResolvedThenable(thenable) {
534
- 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);
535
502
  }
536
503
 
537
504
  function getComponentName(type) {
@@ -561,8 +528,8 @@ function getComponentName(type) {
561
528
  return 'Profiler';
562
529
  case REACT_STRICT_MODE_TYPE:
563
530
  return 'StrictMode';
564
- case REACT_PLACEHOLDER_TYPE:
565
- return 'Placeholder';
531
+ case REACT_SUSPENSE_TYPE:
532
+ return 'Suspense';
566
533
  }
567
534
  if (typeof type === 'object') {
568
535
  switch (type.$$typeof) {
@@ -571,16 +538,17 @@ function getComponentName(type) {
571
538
  case REACT_PROVIDER_TYPE:
572
539
  return 'Context.Provider';
573
540
  case REACT_FORWARD_REF_TYPE:
574
- var renderFn = type.render;
575
- var functionName = renderFn.displayName || renderFn.name || '';
576
- return type.displayName || (functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef');
577
- }
578
- if (typeof type.then === 'function') {
579
- var thenable = type;
580
- var resolvedThenable = refineResolvedThenable(thenable);
581
- if (resolvedThenable) {
582
- return getComponentName(resolvedThenable);
583
- }
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
+ }
584
552
  }
585
553
  }
586
554
  return null;
@@ -1295,12 +1263,6 @@ function onlyChild(children) {
1295
1263
  return children;
1296
1264
  }
1297
1265
 
1298
- function readContext(context, observedBits) {
1299
- var dispatcher = ReactCurrentOwner.currentDispatcher;
1300
- !(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;
1301
- return dispatcher.readContext(context, observedBits);
1302
- }
1303
-
1304
1266
  function createContext(defaultValue, calculateChangedBits) {
1305
1267
  if (calculateChangedBits === undefined) {
1306
1268
  calculateChangedBits = null;
@@ -1320,18 +1282,82 @@ function createContext(defaultValue, calculateChangedBits) {
1320
1282
  // Secondary renderers store their context values on separate fields.
1321
1283
  _currentValue: defaultValue,
1322
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,
1323
1288
  // These are circular
1324
1289
  Provider: null,
1325
- Consumer: null,
1326
- unstable_read: null
1290
+ Consumer: null
1327
1291
  };
1328
1292
 
1329
1293
  context.Provider = {
1330
1294
  $$typeof: REACT_PROVIDER_TYPE,
1331
1295
  _context: context
1332
1296
  };
1333
- context.Consumer = context;
1334
- 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
+ }
1335
1361
 
1336
1362
  {
1337
1363
  context._currentRenderer = null;
@@ -1342,26 +1368,20 @@ function createContext(defaultValue, calculateChangedBits) {
1342
1368
  }
1343
1369
 
1344
1370
  function lazy(ctor) {
1345
- var thenable = null;
1346
1371
  return {
1347
- then: function (resolve, reject) {
1348
- if (thenable === null) {
1349
- // Lazily create thenable by wrapping in an extra thenable.
1350
- thenable = ctor();
1351
- ctor = null;
1352
- }
1353
- return thenable.then(resolve, reject);
1354
- },
1355
-
1372
+ $$typeof: REACT_LAZY_TYPE,
1373
+ _ctor: ctor,
1356
1374
  // React uses these fields to store the result.
1357
- _reactStatus: -1,
1358
- _reactResult: null
1375
+ _status: -1,
1376
+ _result: null
1359
1377
  };
1360
1378
  }
1361
1379
 
1362
1380
  function forwardRef(render) {
1363
1381
  {
1364
- 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') {
1365
1385
  warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
1366
1386
  } else {
1367
1387
  !(
@@ -1380,28 +1400,92 @@ function forwardRef(render) {
1380
1400
  };
1381
1401
  }
1382
1402
 
1383
- 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) {
1384
1410
  {
1385
- if (typeof render !== 'function') {
1386
- warningWithoutStack$1(false, 'pure: The first argument must be a function component. Instead ' + 'received: %s', render === null ? 'null' : typeof render);
1387
- } else {
1388
- var prototype = render.prototype;
1389
- if (prototype && prototype.isReactComponent) {
1390
- warningWithoutStack$1(false, 'pure: The first argument must be a function component. Classes ' + 'are not supported. Use React.PureComponent instead.');
1391
- }
1411
+ if (!isValidElementType(type)) {
1412
+ warningWithoutStack$1(false, 'memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
1392
1413
  }
1393
1414
  }
1394
1415
  return {
1395
- $$typeof: REACT_PURE_TYPE,
1396
- render: render,
1416
+ $$typeof: REACT_MEMO_TYPE,
1417
+ type: type,
1397
1418
  compare: compare === undefined ? null : compare
1398
1419
  };
1399
1420
  }
1400
1421
 
1401
- function isValidElementType(type) {
1402
- return typeof type === 'string' || typeof type === 'function' ||
1403
- // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
1404
- type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_PLACEHOLDER_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);
1405
1489
  }
1406
1490
 
1407
1491
  /**
@@ -1701,12 +1785,12 @@ var React = {
1701
1785
 
1702
1786
  createContext: createContext,
1703
1787
  forwardRef: forwardRef,
1704
- pure: pure,
1788
+ lazy: lazy,
1789
+ memo: memo,
1705
1790
 
1706
1791
  Fragment: REACT_FRAGMENT_TYPE,
1707
1792
  StrictMode: REACT_STRICT_MODE_TYPE,
1708
- unstable_ConcurrentMode: REACT_CONCURRENT_MODE_TYPE,
1709
- unstable_Profiler: REACT_PROFILER_TYPE,
1793
+ Suspense: REACT_SUSPENSE_TYPE,
1710
1794
 
1711
1795
  createElement: createElementWithValidation,
1712
1796
  cloneElement: cloneElementWithValidation,
@@ -1718,9 +1802,25 @@ var React = {
1718
1802
  __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals
1719
1803
  };
1720
1804
 
1721
- if (enableSuspense) {
1722
- React.Placeholder = REACT_PLACEHOLDER_TYPE;
1723
- React.lazy = lazy;
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;
1724
1824
  }
1725
1825
 
1726
1826