react 19.0.0-rc-4c2e457c7c-20240522 → 19.0.0-rc-935180c7e0-20240524

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.
@@ -20,7 +20,7 @@ if (
20
20
  ) {
21
21
  __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
22
22
  }
23
- var ReactVersion = '19.0.0-rc-4c2e457c7c-20240522';
23
+ var ReactVersion = '19.0.0-rc-935180c7e0-20240524';
24
24
 
25
25
  // -----------------------------------------------------------------------------
26
26
 
@@ -78,7 +78,8 @@ function getIteratorFn(maybeIterable) {
78
78
  var ReactSharedInternals = {
79
79
  H: null,
80
80
  A: null,
81
- T: null
81
+ T: null,
82
+ S: null
82
83
  };
83
84
 
84
85
  {
@@ -86,32 +87,9 @@ var ReactSharedInternals = {
86
87
  ReactSharedInternals.isBatchingLegacy = false;
87
88
  ReactSharedInternals.didScheduleLegacyUpdate = false;
88
89
  ReactSharedInternals.didUsePromise = false;
89
- ReactSharedInternals.thrownErrors = [];
90
- var currentExtraStackFrame = null;
91
-
92
- ReactSharedInternals.setExtraStackFrame = function (stack) {
93
- currentExtraStackFrame = stack;
94
- }; // Stack implementation injected by the current renderer.
95
-
90
+ ReactSharedInternals.thrownErrors = []; // Stack implementation injected by the current renderer.
96
91
 
97
92
  ReactSharedInternals.getCurrentStack = null;
98
-
99
- ReactSharedInternals.getStackAddendum = function () {
100
- var stack = ''; // Add an extra top frame while an element is being validated
101
-
102
- if (currentExtraStackFrame) {
103
- stack += currentExtraStackFrame;
104
- } // Delegate to the injected renderer-specific implementation
105
-
106
-
107
- var impl = ReactSharedInternals.getCurrentStack;
108
-
109
- if (impl) {
110
- stack += impl() || '';
111
- }
112
-
113
- return stack;
114
- };
115
93
  }
116
94
 
117
95
  // by calls to these methods by a Babel plugin.
@@ -146,23 +124,36 @@ function printWarning(level, format, args) {
146
124
  // When changing this logic, you might want to also
147
125
  // update consoleWithStackDev.www.js as well.
148
126
  {
149
- var stack = ReactSharedInternals.getStackAddendum();
150
-
151
- if (stack !== '') {
152
- format += '%s';
153
- args = args.concat([stack]);
154
- } // eslint-disable-next-line react-internal/safe-string-coercion
127
+ var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n';
155
128
 
129
+ if (ReactSharedInternals.getCurrentStack) {
130
+ var stack = ReactSharedInternals.getCurrentStack();
156
131
 
157
- var argsWithFormat = args.map(function (item) {
158
- return String(item);
159
- }); // Careful: RN currently depends on this prefix
132
+ if (stack !== '') {
133
+ format += '%s';
134
+ args = args.concat([stack]);
135
+ }
136
+ }
160
137
 
161
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
138
+ if (isErrorLogger) {
139
+ // Don't prefix our default logging formatting in ReactFiberErrorLoggger.
140
+ // Don't toString the arguments.
141
+ args.unshift(format);
142
+ } else {
143
+ // TODO: Remove this prefix and stop toStringing in the wrapper and
144
+ // instead do it at each callsite as needed.
145
+ // Careful: RN currently depends on this prefix
146
+ // eslint-disable-next-line react-internal/safe-string-coercion
147
+ args = args.map(function (item) {
148
+ return String(item);
149
+ });
150
+ args.unshift('Warning: ' + format);
151
+ } // We intentionally don't use spread (or .apply) directly because it
162
152
  // breaks IE9: https://github.com/facebook/react/issues/13610
163
153
  // eslint-disable-next-line react-internal/no-production-logging
164
154
 
165
- Function.prototype.apply.call(console[level], console, argsWithFormat);
155
+
156
+ Function.prototype.apply.call(console[level], console, args);
166
157
  }
167
158
  }
168
159
 
@@ -583,7 +574,9 @@ function getComponentNameFromType(type) {
583
574
  // $FlowFixMe[method-unbinding]
584
575
  var hasOwnProperty = Object.prototype.hasOwnProperty;
585
576
 
586
- var REACT_CLIENT_REFERENCE$1 = Symbol.for('react.client.reference');
577
+ var REACT_CLIENT_REFERENCE$1 = Symbol.for('react.client.reference'); // This function is deprecated. Don't use. Only the renderer knows what a valid type is.
578
+ // TODO: Delete this when enableOwnerStacks ships.
579
+
587
580
  function isValidElementType(type) {
588
581
  if (typeof type === 'string' || typeof type === 'function') {
589
582
  return true;
@@ -975,7 +968,8 @@ function describeFunctionComponentFrame(fn) {
975
968
  function shouldConstruct(Component) {
976
969
  var prototype = Component.prototype;
977
970
  return !!(prototype && prototype.isReactComponent);
978
- }
971
+ } // TODO: Delete this once the key warning no longer uses it. I.e. when enableOwnerStacks ship.
972
+
979
973
 
980
974
  function describeUnknownElementTypeFrameInDEV(type) {
981
975
 
@@ -1207,7 +1201,7 @@ function ReactElement(type, key, _ref, self, source, owner, props, debugStack, d
1207
1201
  configurable: false,
1208
1202
  enumerable: false,
1209
1203
  writable: true,
1210
- value: false
1204
+ value: 0
1211
1205
  }); // debugInfo contains Server Component debug information.
1212
1206
 
1213
1207
  Object.defineProperty(element, '_debugInfo', {
@@ -1233,6 +1227,11 @@ function ReactElement(type, key, _ref, self, source, owner, props, debugStack, d
1233
1227
  function createElement(type, config, children) {
1234
1228
  {
1235
1229
  if (!isValidElementType(type)) {
1230
+ // This is just an optimistic check that provides a better stack trace before
1231
+ // owner stacks. It's really up to the renderer if it's a valid element type.
1232
+ // When owner stacks are enabled, we instead warn in the renderer and it'll
1233
+ // have the stack trace of the JSX element anyway.
1234
+ //
1236
1235
  // This is an invalid element type.
1237
1236
  //
1238
1237
  // We warn in this case but don't throw. We expect the element creation to
@@ -1359,13 +1358,7 @@ function createElement(type, config, children) {
1359
1358
  }
1360
1359
  }
1361
1360
 
1362
- var element = ReactElement(type, key, ref, undefined, undefined, getOwner(), props);
1363
-
1364
- if (type === REACT_FRAGMENT_TYPE) {
1365
- validateFragmentProps(element);
1366
- }
1367
-
1368
- return element;
1361
+ return ReactElement(type, key, ref, undefined, undefined, getOwner(), props);
1369
1362
  }
1370
1363
  function cloneAndReplaceKey(oldElement, newKey) {
1371
1364
  return ReactElement(oldElement.type, newKey, // When enableRefAsProp is on, this argument is ignored. This check only
@@ -1449,22 +1442,6 @@ function cloneElement(element, config, children) {
1449
1442
 
1450
1443
  return clonedElement;
1451
1444
  }
1452
-
1453
- function getDeclarationErrorAddendum() {
1454
- {
1455
- var owner = getOwner();
1456
-
1457
- if (owner) {
1458
- var name = getComponentNameFromType(owner.type);
1459
-
1460
- if (name) {
1461
- return '\n\nCheck the render method of `' + name + '`.';
1462
- }
1463
- }
1464
-
1465
- return '';
1466
- }
1467
- }
1468
1445
  /**
1469
1446
  * Ensure that every element either is passed in a static location, in an
1470
1447
  * array with an explicit keys property defined, or in an object literal
@@ -1475,7 +1452,6 @@ function getDeclarationErrorAddendum() {
1475
1452
  * @param {*} parentType node's parent's type.
1476
1453
  */
1477
1454
 
1478
-
1479
1455
  function validateChildKeys(node, parentType) {
1480
1456
  {
1481
1457
  if (typeof node !== 'object' || !node) {
@@ -1493,7 +1469,7 @@ function validateChildKeys(node, parentType) {
1493
1469
  } else if (isValidElement(node)) {
1494
1470
  // This element was passed in a valid location.
1495
1471
  if (node._store) {
1496
- node._store.validated = true;
1472
+ node._store.validated = 1;
1497
1473
  }
1498
1474
  } else {
1499
1475
  var iteratorFn = getIteratorFn(node);
@@ -1544,12 +1520,13 @@ var ownerHasKeyUseWarning = {};
1544
1520
  */
1545
1521
 
1546
1522
  function validateExplicitKey(element, parentType) {
1523
+
1547
1524
  {
1548
1525
  if (!element._store || element._store.validated || element.key != null) {
1549
1526
  return;
1550
1527
  }
1551
1528
 
1552
- element._store.validated = true;
1529
+ element._store.validated = 1;
1553
1530
  var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1554
1531
 
1555
1532
  if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
@@ -1575,28 +1552,37 @@ function validateExplicitKey(element, parentType) {
1575
1552
  childOwner = " It was passed a child from " + ownerName + ".";
1576
1553
  }
1577
1554
 
1578
- setCurrentlyValidatingElement(element);
1555
+ var prevGetCurrentStack = ReactSharedInternals.getCurrentStack;
1579
1556
 
1580
- error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
1557
+ ReactSharedInternals.getCurrentStack = function () {
1581
1558
 
1582
- setCurrentlyValidatingElement(null);
1583
- }
1584
- }
1559
+ var stack = describeUnknownElementTypeFrameInDEV(element.type); // Delegate to the injected renderer-specific implementation
1585
1560
 
1586
- function setCurrentlyValidatingElement(element) {
1587
- {
1588
- if (element) {
1589
- var stack = describeUnknownElementTypeFrameInDEV(element.type);
1590
- ReactSharedInternals.setExtraStackFrame(stack);
1591
- } else {
1592
- ReactSharedInternals.setExtraStackFrame(null);
1593
- }
1561
+ if (prevGetCurrentStack) {
1562
+ stack += prevGetCurrentStack() || '';
1563
+ }
1564
+
1565
+ return stack;
1566
+ };
1567
+
1568
+ error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
1569
+
1570
+ ReactSharedInternals.getCurrentStack = prevGetCurrentStack;
1594
1571
  }
1595
1572
  }
1596
1573
 
1597
1574
  function getCurrentComponentErrorInfo(parentType) {
1598
1575
  {
1599
- var info = getDeclarationErrorAddendum();
1576
+ var info = '';
1577
+ var owner = getOwner();
1578
+
1579
+ if (owner) {
1580
+ var name = getComponentNameFromType(owner.type);
1581
+
1582
+ if (name) {
1583
+ info = '\n\nCheck the render method of `' + name + '`.';
1584
+ }
1585
+ }
1600
1586
 
1601
1587
  if (!info) {
1602
1588
  var parentName = getComponentNameFromType(parentType);
@@ -1609,31 +1595,6 @@ function getCurrentComponentErrorInfo(parentType) {
1609
1595
  return info;
1610
1596
  }
1611
1597
  }
1612
- /**
1613
- * Given a fragment, validate that it can only be provided with fragment props
1614
- * @param {ReactElement} fragment
1615
- */
1616
-
1617
-
1618
- function validateFragmentProps(fragment) {
1619
- // TODO: Move this to render phase instead of at element creation.
1620
- {
1621
- var keys = Object.keys(fragment.props);
1622
-
1623
- for (var i = 0; i < keys.length; i++) {
1624
- var key = keys[i];
1625
-
1626
- if (key !== 'children' && key !== 'key') {
1627
- setCurrentlyValidatingElement(fragment);
1628
-
1629
- error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
1630
-
1631
- setCurrentlyValidatingElement(null);
1632
- break;
1633
- }
1634
- }
1635
- }
1636
- }
1637
1598
 
1638
1599
  var SEPARATOR = '.';
1639
1600
  var SUBSEPARATOR = ':';
@@ -1817,17 +1778,32 @@ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
1817
1778
  // The `if` statement here prevents auto-disabling of the safe
1818
1779
  // coercion ESLint rule, so we must manually disable it below.
1819
1780
  // $FlowFixMe[incompatible-type] Flow incorrectly thinks React.Portal doesn't have a key
1820
- if (mappedChild.key && (!_child || _child.key !== mappedChild.key)) {
1821
- checkKeyStringCoercion(mappedChild.key);
1781
+ if (mappedChild.key != null) {
1782
+ if (!_child || _child.key !== mappedChild.key) {
1783
+ checkKeyStringCoercion(mappedChild.key);
1784
+ }
1822
1785
  }
1823
1786
  }
1824
1787
 
1825
- mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as
1788
+ var newChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as
1826
1789
  // traverseAllChildren used to do for objects as children
1827
1790
  escapedPrefix + ( // $FlowFixMe[incompatible-type] Flow incorrectly thinks React.Portal doesn't have a key
1828
- mappedChild.key && (!_child || _child.key !== mappedChild.key) ? escapeUserProvidedKey( // $FlowFixMe[unsafe-addition]
1791
+ mappedChild.key != null && (!_child || _child.key !== mappedChild.key) ? escapeUserProvidedKey( // $FlowFixMe[unsafe-addition]
1829
1792
  '' + mappedChild.key // eslint-disable-line react-internal/safe-string-coercion
1830
1793
  ) + '/' : '') + childKey);
1794
+
1795
+ {
1796
+ if (nameSoFar !== '' && mappedChild.key == null) {
1797
+ // We need to validate that this child should have had a key before assigning it one.
1798
+ if (!newChild._store.validated) {
1799
+ // We mark this child as having failed validation but we let the actual renderer
1800
+ // print the warning later.
1801
+ newChild._store.validated = 2;
1802
+ }
1803
+ }
1804
+ }
1805
+
1806
+ mappedChild = newChild;
1831
1807
  }
1832
1808
 
1833
1809
  array.push(mappedChild);
@@ -2350,13 +2326,8 @@ reportError : function (error) {
2350
2326
  };
2351
2327
 
2352
2328
  function startTransition(scope, options) {
2353
- var prevTransition = ReactSharedInternals.T; // Each renderer registers a callback to receive the return value of
2354
- // the scope function. This is used to implement async actions.
2355
-
2356
- var callbacks = new Set();
2357
- var transition = {
2358
- _callbacks: callbacks
2359
- };
2329
+ var prevTransition = ReactSharedInternals.T;
2330
+ var transition = {};
2360
2331
  ReactSharedInternals.T = transition;
2361
2332
  var currentTransition = ReactSharedInternals.T;
2362
2333
 
@@ -2367,11 +2338,13 @@ function startTransition(scope, options) {
2367
2338
  {
2368
2339
  try {
2369
2340
  var returnValue = scope();
2341
+ var onStartTransitionFinish = ReactSharedInternals.S;
2342
+
2343
+ if (onStartTransitionFinish !== null) {
2344
+ onStartTransitionFinish(transition, returnValue);
2345
+ }
2370
2346
 
2371
2347
  if (typeof returnValue === 'object' && returnValue !== null && typeof returnValue.then === 'function') {
2372
- callbacks.forEach(function (callback) {
2373
- return callback(currentTransition, returnValue);
2374
- });
2375
2348
  returnValue.then(noop, reportGlobalError);
2376
2349
  }
2377
2350
  } catch (error) {
@@ -72,7 +72,7 @@ pureComponentPrototype.constructor = PureComponent;
72
72
  assign(pureComponentPrototype, Component.prototype);
73
73
  pureComponentPrototype.isPureReactComponent = !0;
74
74
  var isArrayImpl = Array.isArray,
75
- ReactSharedInternals = { H: null, A: null, T: null },
75
+ ReactSharedInternals = { H: null, A: null, T: null, S: null },
76
76
  hasOwnProperty = Object.prototype.hasOwnProperty;
77
77
  function ReactElement(type, key, _ref, self, source, owner, props) {
78
78
  _ref = props.ref;
@@ -199,7 +199,8 @@ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
199
199
  (callback = cloneAndReplaceKey(
200
200
  callback,
201
201
  escapedPrefix +
202
- (!callback.key || (children && children.key === callback.key)
202
+ (null == callback.key ||
203
+ (children && children.key === callback.key)
203
204
  ? ""
204
205
  : ("" + callback.key).replace(
205
206
  userProvidedKeyEscapeRegex,
@@ -455,18 +456,17 @@ exports.memo = function (type, compare) {
455
456
  };
456
457
  exports.startTransition = function (scope) {
457
458
  var prevTransition = ReactSharedInternals.T,
458
- callbacks = new Set();
459
- ReactSharedInternals.T = { _callbacks: callbacks };
460
- var currentTransition = ReactSharedInternals.T;
459
+ transition = {};
460
+ ReactSharedInternals.T = transition;
461
461
  try {
462
- var returnValue = scope();
462
+ var returnValue = scope(),
463
+ onStartTransitionFinish = ReactSharedInternals.S;
464
+ null !== onStartTransitionFinish &&
465
+ onStartTransitionFinish(transition, returnValue);
463
466
  "object" === typeof returnValue &&
464
467
  null !== returnValue &&
465
468
  "function" === typeof returnValue.then &&
466
- (callbacks.forEach(function (callback) {
467
- return callback(currentTransition, returnValue);
468
- }),
469
- returnValue.then(noop, reportGlobalError));
469
+ returnValue.then(noop, reportGlobalError);
470
470
  } catch (error) {
471
471
  reportGlobalError(error);
472
472
  } finally {
@@ -536,4 +536,4 @@ exports.useSyncExternalStore = function (
536
536
  exports.useTransition = function () {
537
537
  return ReactSharedInternals.H.useTransition();
538
538
  };
539
- exports.version = "19.0.0-rc-4c2e457c7c-20240522";
539
+ exports.version = "19.0.0-rc-935180c7e0-20240524";