react 19.0.0-rc-4c2e457c7c-20240522 → 19.0.0-rc-6f23540c7d-20240528

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.
@@ -77,29 +77,45 @@ function error(format) {
77
77
  printWarning('error', format, args);
78
78
  }
79
79
  }
80
- }
80
+ } // eslint-disable-next-line react-internal/no-production-logging
81
81
 
82
82
  function printWarning(level, format, args) {
83
83
  // When changing this logic, you might want to also
84
84
  // update consoleWithStackDev.www.js as well.
85
85
  {
86
- var stack = ReactSharedInternals.getStackAddendum();
87
-
88
- if (stack !== '') {
89
- format += '%s';
90
- args = args.concat([stack]);
91
- } // eslint-disable-next-line react-internal/safe-string-coercion
86
+ var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n';
92
87
 
88
+ if (ReactSharedInternals.getCurrentStack) {
89
+ // We only add the current stack to the console when createTask is not supported.
90
+ // Since createTask requires DevTools to be open to work, this means that stacks
91
+ // can be lost while DevTools isn't open but we can't detect this.
92
+ var stack = ReactSharedInternals.getCurrentStack();
93
93
 
94
- var argsWithFormat = args.map(function (item) {
95
- return String(item);
96
- }); // Careful: RN currently depends on this prefix
94
+ if (stack !== '') {
95
+ format += '%s';
96
+ args = args.concat([stack]);
97
+ }
98
+ }
97
99
 
98
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
100
+ if (isErrorLogger) {
101
+ // Don't prefix our default logging formatting in ReactFiberErrorLoggger.
102
+ // Don't toString the arguments.
103
+ args.unshift(format);
104
+ } else {
105
+ // TODO: Remove this prefix and stop toStringing in the wrapper and
106
+ // instead do it at each callsite as needed.
107
+ // Careful: RN currently depends on this prefix
108
+ // eslint-disable-next-line react-internal/safe-string-coercion
109
+ args = args.map(function (item) {
110
+ return String(item);
111
+ });
112
+ args.unshift('Warning: ' + format);
113
+ } // We intentionally don't use spread (or .apply) directly because it
99
114
  // breaks IE9: https://github.com/facebook/react/issues/13610
100
115
  // eslint-disable-next-line react-internal/no-production-logging
101
116
 
102
- Function.prototype.apply.call(console[level], console, argsWithFormat);
117
+
118
+ Function.prototype.apply.call(console[level], console, args);
103
119
  }
104
120
  }
105
121
 
@@ -290,7 +306,9 @@ function checkKeyStringCoercion(value) {
290
306
  }
291
307
  }
292
308
 
293
- var REACT_CLIENT_REFERENCE$1 = Symbol.for('react.client.reference');
309
+ 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.
310
+ // TODO: Delete this when enableOwnerStacks ships.
311
+
294
312
  function isValidElementType(type) {
295
313
  if (typeof type === 'string' || typeof type === 'function') {
296
314
  return true;
@@ -688,7 +706,8 @@ function describeFunctionComponentFrame(fn) {
688
706
  function shouldConstruct(Component) {
689
707
  var prototype = Component.prototype;
690
708
  return !!(prototype && prototype.isReactComponent);
691
- }
709
+ } // TODO: Delete this once the key warning no longer uses it. I.e. when enableOwnerStacks ship.
710
+
692
711
 
693
712
  function describeUnknownElementTypeFrameInDEV(type) {
694
713
 
@@ -919,7 +938,7 @@ function ReactElement(type, key, _ref, self, source, owner, props, debugStack, d
919
938
  configurable: false,
920
939
  enumerable: false,
921
940
  writable: true,
922
- value: false
941
+ value: 0
923
942
  }); // debugInfo contains Server Component debug information.
924
943
 
925
944
  Object.defineProperty(element, '_debugInfo', {
@@ -952,24 +971,18 @@ function ReactElement(type, key, _ref, self, source, owner, props, debugStack, d
952
971
  function jsxProdSignatureRunningInDevWithDynamicChildren(type, config, maybeKey, source, self) {
953
972
  {
954
973
  var isStaticChildren = false;
955
- return jsxDEV(type, config, maybeKey, isStaticChildren, source, self);
974
+ return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self);
956
975
  }
957
976
  }
958
977
  function jsxProdSignatureRunningInDevWithStaticChildren(type, config, maybeKey, source, self) {
959
978
  {
960
979
  var isStaticChildren = true;
961
- return jsxDEV(type, config, maybeKey, isStaticChildren, source, self);
980
+ return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self);
962
981
  }
963
982
  }
964
983
  var didWarnAboutKeySpread = {};
965
- /**
966
- * https://github.com/reactjs/rfcs/pull/107
967
- * @param {*} type
968
- * @param {object} props
969
- * @param {string} key
970
- */
971
984
 
972
- function jsxDEV(type, config, maybeKey, isStaticChildren, source, self) {
985
+ function jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self, debugStack, debugTask) {
973
986
  {
974
987
  if (!isValidElementType(type)) {
975
988
  // This is an invalid element type.
@@ -1104,29 +1117,7 @@ function jsxDEV(type, config, maybeKey, isStaticChildren, source, self) {
1104
1117
  }
1105
1118
  }
1106
1119
 
1107
- var element = ReactElement(type, key, ref, self, source, getOwner(), props);
1108
-
1109
- if (type === REACT_FRAGMENT_TYPE) {
1110
- validateFragmentProps(element);
1111
- }
1112
-
1113
- return element;
1114
- }
1115
- }
1116
-
1117
- function getDeclarationErrorAddendum() {
1118
- {
1119
- var owner = getOwner();
1120
-
1121
- if (owner) {
1122
- var name = getComponentNameFromType(owner.type);
1123
-
1124
- if (name) {
1125
- return '\n\nCheck the render method of `' + name + '`.';
1126
- }
1127
- }
1128
-
1129
- return '';
1120
+ return ReactElement(type, key, ref, self, source, getOwner(), props);
1130
1121
  }
1131
1122
  }
1132
1123
  /**
@@ -1139,7 +1130,6 @@ function getDeclarationErrorAddendum() {
1139
1130
  * @param {*} parentType node's parent's type.
1140
1131
  */
1141
1132
 
1142
-
1143
1133
  function validateChildKeys(node, parentType) {
1144
1134
  {
1145
1135
  if (typeof node !== 'object' || !node) {
@@ -1157,7 +1147,7 @@ function validateChildKeys(node, parentType) {
1157
1147
  } else if (isValidElement(node)) {
1158
1148
  // This element was passed in a valid location.
1159
1149
  if (node._store) {
1160
- node._store.validated = true;
1150
+ node._store.validated = 1;
1161
1151
  }
1162
1152
  } else {
1163
1153
  var iteratorFn = getIteratorFn(node);
@@ -1208,12 +1198,13 @@ var ownerHasKeyUseWarning = {};
1208
1198
  */
1209
1199
 
1210
1200
  function validateExplicitKey(element, parentType) {
1201
+
1211
1202
  {
1212
1203
  if (!element._store || element._store.validated || element.key != null) {
1213
1204
  return;
1214
1205
  }
1215
1206
 
1216
- element._store.validated = true;
1207
+ element._store.validated = 1;
1217
1208
  var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1218
1209
 
1219
1210
  if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
@@ -1239,28 +1230,37 @@ function validateExplicitKey(element, parentType) {
1239
1230
  childOwner = " It was passed a child from " + ownerName + ".";
1240
1231
  }
1241
1232
 
1242
- setCurrentlyValidatingElement(element);
1233
+ var prevGetCurrentStack = ReactSharedInternals.getCurrentStack;
1243
1234
 
1244
- 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);
1235
+ ReactSharedInternals.getCurrentStack = function () {
1245
1236
 
1246
- setCurrentlyValidatingElement(null);
1247
- }
1248
- }
1237
+ var stack = describeUnknownElementTypeFrameInDEV(element.type); // Delegate to the injected renderer-specific implementation
1249
1238
 
1250
- function setCurrentlyValidatingElement(element) {
1251
- {
1252
- if (element) {
1253
- var stack = describeUnknownElementTypeFrameInDEV(element.type);
1254
- ReactSharedInternals.setExtraStackFrame(stack);
1255
- } else {
1256
- ReactSharedInternals.setExtraStackFrame(null);
1257
- }
1239
+ if (prevGetCurrentStack) {
1240
+ stack += prevGetCurrentStack() || '';
1241
+ }
1242
+
1243
+ return stack;
1244
+ };
1245
+
1246
+ 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);
1247
+
1248
+ ReactSharedInternals.getCurrentStack = prevGetCurrentStack;
1258
1249
  }
1259
1250
  }
1260
1251
 
1261
1252
  function getCurrentComponentErrorInfo(parentType) {
1262
1253
  {
1263
- var info = getDeclarationErrorAddendum();
1254
+ var info = '';
1255
+ var owner = getOwner();
1256
+
1257
+ if (owner) {
1258
+ var name = getComponentNameFromType(owner.type);
1259
+
1260
+ if (name) {
1261
+ info = '\n\nCheck the render method of `' + name + '`.';
1262
+ }
1263
+ }
1264
1264
 
1265
1265
  if (!info) {
1266
1266
  var parentName = getComponentNameFromType(parentType);
@@ -1273,31 +1273,6 @@ function getCurrentComponentErrorInfo(parentType) {
1273
1273
  return info;
1274
1274
  }
1275
1275
  }
1276
- /**
1277
- * Given a fragment, validate that it can only be provided with fragment props
1278
- * @param {ReactElement} fragment
1279
- */
1280
-
1281
-
1282
- function validateFragmentProps(fragment) {
1283
- // TODO: Move this to render phase instead of at element creation.
1284
- {
1285
- var keys = Object.keys(fragment.props);
1286
-
1287
- for (var i = 0; i < keys.length; i++) {
1288
- var key = keys[i];
1289
-
1290
- if (key !== 'children' && key !== 'key') {
1291
- setCurrentlyValidatingElement(fragment);
1292
-
1293
- error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
1294
-
1295
- setCurrentlyValidatingElement(null);
1296
- break;
1297
- }
1298
- }
1299
- }
1300
- }
1301
1276
 
1302
1277
  var jsx = jsxProdSignatureRunningInDevWithDynamicChildren ; // we may want to special case jsxs internally to take advantage of static children.
1303
1278
  // for now we can ship identical prod functions
@@ -82,29 +82,45 @@ function error(format) {
82
82
  printWarning('error', format, args);
83
83
  }
84
84
  }
85
- }
85
+ } // eslint-disable-next-line react-internal/no-production-logging
86
86
 
87
87
  function printWarning(level, format, args) {
88
88
  // When changing this logic, you might want to also
89
89
  // update consoleWithStackDev.www.js as well.
90
90
  {
91
- var stack = ReactSharedInternalsServer.getStackAddendum();
92
-
93
- if (stack !== '') {
94
- format += '%s';
95
- args = args.concat([stack]);
96
- } // eslint-disable-next-line react-internal/safe-string-coercion
91
+ var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n';
97
92
 
93
+ if (ReactSharedInternalsServer.getCurrentStack) {
94
+ // We only add the current stack to the console when createTask is not supported.
95
+ // Since createTask requires DevTools to be open to work, this means that stacks
96
+ // can be lost while DevTools isn't open but we can't detect this.
97
+ var stack = ReactSharedInternalsServer.getCurrentStack();
98
98
 
99
- var argsWithFormat = args.map(function (item) {
100
- return String(item);
101
- }); // Careful: RN currently depends on this prefix
99
+ if (stack !== '') {
100
+ format += '%s';
101
+ args = args.concat([stack]);
102
+ }
103
+ }
102
104
 
103
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
105
+ if (isErrorLogger) {
106
+ // Don't prefix our default logging formatting in ReactFiberErrorLoggger.
107
+ // Don't toString the arguments.
108
+ args.unshift(format);
109
+ } else {
110
+ // TODO: Remove this prefix and stop toStringing in the wrapper and
111
+ // instead do it at each callsite as needed.
112
+ // Careful: RN currently depends on this prefix
113
+ // eslint-disable-next-line react-internal/safe-string-coercion
114
+ args = args.map(function (item) {
115
+ return String(item);
116
+ });
117
+ args.unshift('Warning: ' + format);
118
+ } // We intentionally don't use spread (or .apply) directly because it
104
119
  // breaks IE9: https://github.com/facebook/react/issues/13610
105
120
  // eslint-disable-next-line react-internal/no-production-logging
106
121
 
107
- Function.prototype.apply.call(console[level], console, argsWithFormat);
122
+
123
+ Function.prototype.apply.call(console[level], console, args);
108
124
  }
109
125
  }
110
126
 
@@ -295,7 +311,9 @@ function checkKeyStringCoercion(value) {
295
311
  }
296
312
  }
297
313
 
298
- var REACT_CLIENT_REFERENCE$1 = Symbol.for('react.client.reference');
314
+ 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.
315
+ // TODO: Delete this when enableOwnerStacks ships.
316
+
299
317
  function isValidElementType(type) {
300
318
  if (typeof type === 'string' || typeof type === 'function') {
301
319
  return true;
@@ -693,7 +711,8 @@ function describeFunctionComponentFrame(fn) {
693
711
  function shouldConstruct(Component) {
694
712
  var prototype = Component.prototype;
695
713
  return !!(prototype && prototype.isReactComponent);
696
- }
714
+ } // TODO: Delete this once the key warning no longer uses it. I.e. when enableOwnerStacks ship.
715
+
697
716
 
698
717
  function describeUnknownElementTypeFrameInDEV(type) {
699
718
 
@@ -924,7 +943,7 @@ function ReactElement(type, key, _ref, self, source, owner, props, debugStack, d
924
943
  configurable: false,
925
944
  enumerable: false,
926
945
  writable: true,
927
- value: false
946
+ value: 0
928
947
  }); // debugInfo contains Server Component debug information.
929
948
 
930
949
  Object.defineProperty(element, '_debugInfo', {
@@ -957,13 +976,13 @@ function ReactElement(type, key, _ref, self, source, owner, props, debugStack, d
957
976
  function jsxProdSignatureRunningInDevWithDynamicChildren(type, config, maybeKey, source, self) {
958
977
  {
959
978
  var isStaticChildren = false;
960
- return jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self);
979
+ return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self);
961
980
  }
962
981
  }
963
982
  function jsxProdSignatureRunningInDevWithStaticChildren(type, config, maybeKey, source, self) {
964
983
  {
965
984
  var isStaticChildren = true;
966
- return jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self);
985
+ return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self);
967
986
  }
968
987
  }
969
988
  var didWarnAboutKeySpread = {};
@@ -975,6 +994,10 @@ var didWarnAboutKeySpread = {};
975
994
  */
976
995
 
977
996
  function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) {
997
+ return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self);
998
+ }
999
+
1000
+ function jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self, debugStack, debugTask) {
978
1001
  {
979
1002
  if (!isValidElementType(type)) {
980
1003
  // This is an invalid element type.
@@ -1109,29 +1132,7 @@ function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) {
1109
1132
  }
1110
1133
  }
1111
1134
 
1112
- var element = ReactElement(type, key, ref, self, source, getOwner(), props);
1113
-
1114
- if (type === REACT_FRAGMENT_TYPE) {
1115
- validateFragmentProps(element);
1116
- }
1117
-
1118
- return element;
1119
- }
1120
- }
1121
-
1122
- function getDeclarationErrorAddendum() {
1123
- {
1124
- var owner = getOwner();
1125
-
1126
- if (owner) {
1127
- var name = getComponentNameFromType(owner.type);
1128
-
1129
- if (name) {
1130
- return '\n\nCheck the render method of `' + name + '`.';
1131
- }
1132
- }
1133
-
1134
- return '';
1135
+ return ReactElement(type, key, ref, self, source, getOwner(), props);
1135
1136
  }
1136
1137
  }
1137
1138
  /**
@@ -1144,7 +1145,6 @@ function getDeclarationErrorAddendum() {
1144
1145
  * @param {*} parentType node's parent's type.
1145
1146
  */
1146
1147
 
1147
-
1148
1148
  function validateChildKeys(node, parentType) {
1149
1149
  {
1150
1150
  if (typeof node !== 'object' || !node) {
@@ -1162,7 +1162,7 @@ function validateChildKeys(node, parentType) {
1162
1162
  } else if (isValidElement(node)) {
1163
1163
  // This element was passed in a valid location.
1164
1164
  if (node._store) {
1165
- node._store.validated = true;
1165
+ node._store.validated = 1;
1166
1166
  }
1167
1167
  } else {
1168
1168
  var iteratorFn = getIteratorFn(node);
@@ -1213,12 +1213,13 @@ var ownerHasKeyUseWarning = {};
1213
1213
  */
1214
1214
 
1215
1215
  function validateExplicitKey(element, parentType) {
1216
+
1216
1217
  {
1217
1218
  if (!element._store || element._store.validated || element.key != null) {
1218
1219
  return;
1219
1220
  }
1220
1221
 
1221
- element._store.validated = true;
1222
+ element._store.validated = 1;
1222
1223
  var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1223
1224
 
1224
1225
  if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
@@ -1244,28 +1245,37 @@ function validateExplicitKey(element, parentType) {
1244
1245
  childOwner = " It was passed a child from " + ownerName + ".";
1245
1246
  }
1246
1247
 
1247
- setCurrentlyValidatingElement(element);
1248
+ var prevGetCurrentStack = ReactSharedInternalsServer.getCurrentStack;
1248
1249
 
1249
- 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);
1250
+ ReactSharedInternalsServer.getCurrentStack = function () {
1250
1251
 
1251
- setCurrentlyValidatingElement(null);
1252
- }
1253
- }
1252
+ var stack = describeUnknownElementTypeFrameInDEV(element.type); // Delegate to the injected renderer-specific implementation
1254
1253
 
1255
- function setCurrentlyValidatingElement(element) {
1256
- {
1257
- if (element) {
1258
- var stack = describeUnknownElementTypeFrameInDEV(element.type);
1259
- ReactSharedInternalsServer.setExtraStackFrame(stack);
1260
- } else {
1261
- ReactSharedInternalsServer.setExtraStackFrame(null);
1262
- }
1254
+ if (prevGetCurrentStack) {
1255
+ stack += prevGetCurrentStack() || '';
1256
+ }
1257
+
1258
+ return stack;
1259
+ };
1260
+
1261
+ 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);
1262
+
1263
+ ReactSharedInternalsServer.getCurrentStack = prevGetCurrentStack;
1263
1264
  }
1264
1265
  }
1265
1266
 
1266
1267
  function getCurrentComponentErrorInfo(parentType) {
1267
1268
  {
1268
- var info = getDeclarationErrorAddendum();
1269
+ var info = '';
1270
+ var owner = getOwner();
1271
+
1272
+ if (owner) {
1273
+ var name = getComponentNameFromType(owner.type);
1274
+
1275
+ if (name) {
1276
+ info = '\n\nCheck the render method of `' + name + '`.';
1277
+ }
1278
+ }
1269
1279
 
1270
1280
  if (!info) {
1271
1281
  var parentName = getComponentNameFromType(parentType);
@@ -1278,31 +1288,6 @@ function getCurrentComponentErrorInfo(parentType) {
1278
1288
  return info;
1279
1289
  }
1280
1290
  }
1281
- /**
1282
- * Given a fragment, validate that it can only be provided with fragment props
1283
- * @param {ReactElement} fragment
1284
- */
1285
-
1286
-
1287
- function validateFragmentProps(fragment) {
1288
- // TODO: Move this to render phase instead of at element creation.
1289
- {
1290
- var keys = Object.keys(fragment.props);
1291
-
1292
- for (var i = 0; i < keys.length; i++) {
1293
- var key = keys[i];
1294
-
1295
- if (key !== 'children' && key !== 'key') {
1296
- setCurrentlyValidatingElement(fragment);
1297
-
1298
- error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
1299
-
1300
- setCurrentlyValidatingElement(null);
1301
- break;
1302
- }
1303
- }
1304
- }
1305
- }
1306
1291
 
1307
1292
  var jsx = jsxProdSignatureRunningInDevWithDynamicChildren ; // we may want to special case jsxs internally to take advantage of static children.
1308
1293
  // for now we can ship identical prod functions