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.
@@ -34,23 +34,36 @@ function printWarning(level, format, args) {
34
34
  // When changing this logic, you might want to also
35
35
  // update consoleWithStackDev.www.js as well.
36
36
  {
37
- var stack = ReactSharedInternals.getStackAddendum();
37
+ var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n';
38
38
 
39
- if (stack !== '') {
40
- format += '%s';
41
- args = args.concat([stack]);
42
- } // eslint-disable-next-line react-internal/safe-string-coercion
39
+ if (ReactSharedInternals.getCurrentStack) {
40
+ var stack = ReactSharedInternals.getCurrentStack();
43
41
 
42
+ if (stack !== '') {
43
+ format += '%s';
44
+ args = args.concat([stack]);
45
+ }
46
+ }
44
47
 
45
- var argsWithFormat = args.map(function (item) {
46
- return String(item);
47
- }); // Careful: RN currently depends on this prefix
48
-
49
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
48
+ if (isErrorLogger) {
49
+ // Don't prefix our default logging formatting in ReactFiberErrorLoggger.
50
+ // Don't toString the arguments.
51
+ args.unshift(format);
52
+ } else {
53
+ // TODO: Remove this prefix and stop toStringing in the wrapper and
54
+ // instead do it at each callsite as needed.
55
+ // Careful: RN currently depends on this prefix
56
+ // eslint-disable-next-line react-internal/safe-string-coercion
57
+ args = args.map(function (item) {
58
+ return String(item);
59
+ });
60
+ args.unshift('Warning: ' + format);
61
+ } // We intentionally don't use spread (or .apply) directly because it
50
62
  // breaks IE9: https://github.com/facebook/react/issues/13610
51
63
  // eslint-disable-next-line react-internal/no-production-logging
52
64
 
53
- Function.prototype.apply.call(console[level], console, argsWithFormat);
65
+
66
+ Function.prototype.apply.call(console[level], console, args);
54
67
  }
55
68
  }
56
69
 
@@ -83,23 +83,36 @@ 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();
86
+ var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n';
87
87
 
88
- if (stack !== '') {
89
- format += '%s';
90
- args = args.concat([stack]);
91
- } // eslint-disable-next-line react-internal/safe-string-coercion
88
+ if (ReactSharedInternals.getCurrentStack) {
89
+ var stack = ReactSharedInternals.getCurrentStack();
92
90
 
91
+ if (stack !== '') {
92
+ format += '%s';
93
+ args = args.concat([stack]);
94
+ }
95
+ }
93
96
 
94
- var argsWithFormat = args.map(function (item) {
95
- return String(item);
96
- }); // Careful: RN currently depends on this prefix
97
-
98
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
97
+ if (isErrorLogger) {
98
+ // Don't prefix our default logging formatting in ReactFiberErrorLoggger.
99
+ // Don't toString the arguments.
100
+ args.unshift(format);
101
+ } else {
102
+ // TODO: Remove this prefix and stop toStringing in the wrapper and
103
+ // instead do it at each callsite as needed.
104
+ // Careful: RN currently depends on this prefix
105
+ // eslint-disable-next-line react-internal/safe-string-coercion
106
+ args = args.map(function (item) {
107
+ return String(item);
108
+ });
109
+ args.unshift('Warning: ' + format);
110
+ } // We intentionally don't use spread (or .apply) directly because it
99
111
  // breaks IE9: https://github.com/facebook/react/issues/13610
100
112
  // eslint-disable-next-line react-internal/no-production-logging
101
113
 
102
- Function.prototype.apply.call(console[level], console, argsWithFormat);
114
+
115
+ Function.prototype.apply.call(console[level], console, args);
103
116
  }
104
117
  }
105
118
 
@@ -290,7 +303,9 @@ function checkKeyStringCoercion(value) {
290
303
  }
291
304
  }
292
305
 
293
- var REACT_CLIENT_REFERENCE$1 = Symbol.for('react.client.reference');
306
+ 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.
307
+ // TODO: Delete this when enableOwnerStacks ships.
308
+
294
309
  function isValidElementType(type) {
295
310
  if (typeof type === 'string' || typeof type === 'function') {
296
311
  return true;
@@ -688,7 +703,8 @@ function describeFunctionComponentFrame(fn) {
688
703
  function shouldConstruct(Component) {
689
704
  var prototype = Component.prototype;
690
705
  return !!(prototype && prototype.isReactComponent);
691
- }
706
+ } // TODO: Delete this once the key warning no longer uses it. I.e. when enableOwnerStacks ship.
707
+
692
708
 
693
709
  function describeUnknownElementTypeFrameInDEV(type) {
694
710
 
@@ -919,7 +935,7 @@ function ReactElement(type, key, _ref, self, source, owner, props, debugStack, d
919
935
  configurable: false,
920
936
  enumerable: false,
921
937
  writable: true,
922
- value: false
938
+ value: 0
923
939
  }); // debugInfo contains Server Component debug information.
924
940
 
925
941
  Object.defineProperty(element, '_debugInfo', {
@@ -1080,29 +1096,7 @@ function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) {
1080
1096
  }
1081
1097
  }
1082
1098
 
1083
- var element = ReactElement(type, key, ref, self, source, getOwner(), props);
1084
-
1085
- if (type === REACT_FRAGMENT_TYPE) {
1086
- validateFragmentProps(element);
1087
- }
1088
-
1089
- return element;
1090
- }
1091
- }
1092
-
1093
- function getDeclarationErrorAddendum() {
1094
- {
1095
- var owner = getOwner();
1096
-
1097
- if (owner) {
1098
- var name = getComponentNameFromType(owner.type);
1099
-
1100
- if (name) {
1101
- return '\n\nCheck the render method of `' + name + '`.';
1102
- }
1103
- }
1104
-
1105
- return '';
1099
+ return ReactElement(type, key, ref, self, source, getOwner(), props);
1106
1100
  }
1107
1101
  }
1108
1102
  /**
@@ -1115,7 +1109,6 @@ function getDeclarationErrorAddendum() {
1115
1109
  * @param {*} parentType node's parent's type.
1116
1110
  */
1117
1111
 
1118
-
1119
1112
  function validateChildKeys(node, parentType) {
1120
1113
  {
1121
1114
  if (typeof node !== 'object' || !node) {
@@ -1133,7 +1126,7 @@ function validateChildKeys(node, parentType) {
1133
1126
  } else if (isValidElement(node)) {
1134
1127
  // This element was passed in a valid location.
1135
1128
  if (node._store) {
1136
- node._store.validated = true;
1129
+ node._store.validated = 1;
1137
1130
  }
1138
1131
  } else {
1139
1132
  var iteratorFn = getIteratorFn(node);
@@ -1184,12 +1177,13 @@ var ownerHasKeyUseWarning = {};
1184
1177
  */
1185
1178
 
1186
1179
  function validateExplicitKey(element, parentType) {
1180
+
1187
1181
  {
1188
1182
  if (!element._store || element._store.validated || element.key != null) {
1189
1183
  return;
1190
1184
  }
1191
1185
 
1192
- element._store.validated = true;
1186
+ element._store.validated = 1;
1193
1187
  var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1194
1188
 
1195
1189
  if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
@@ -1215,28 +1209,37 @@ function validateExplicitKey(element, parentType) {
1215
1209
  childOwner = " It was passed a child from " + ownerName + ".";
1216
1210
  }
1217
1211
 
1218
- setCurrentlyValidatingElement(element);
1212
+ var prevGetCurrentStack = ReactSharedInternals.getCurrentStack;
1219
1213
 
1220
- 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);
1214
+ ReactSharedInternals.getCurrentStack = function () {
1221
1215
 
1222
- setCurrentlyValidatingElement(null);
1223
- }
1224
- }
1216
+ var stack = describeUnknownElementTypeFrameInDEV(element.type); // Delegate to the injected renderer-specific implementation
1225
1217
 
1226
- function setCurrentlyValidatingElement(element) {
1227
- {
1228
- if (element) {
1229
- var stack = describeUnknownElementTypeFrameInDEV(element.type);
1230
- ReactSharedInternals.setExtraStackFrame(stack);
1231
- } else {
1232
- ReactSharedInternals.setExtraStackFrame(null);
1233
- }
1218
+ if (prevGetCurrentStack) {
1219
+ stack += prevGetCurrentStack() || '';
1220
+ }
1221
+
1222
+ return stack;
1223
+ };
1224
+
1225
+ 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);
1226
+
1227
+ ReactSharedInternals.getCurrentStack = prevGetCurrentStack;
1234
1228
  }
1235
1229
  }
1236
1230
 
1237
1231
  function getCurrentComponentErrorInfo(parentType) {
1238
1232
  {
1239
- var info = getDeclarationErrorAddendum();
1233
+ var info = '';
1234
+ var owner = getOwner();
1235
+
1236
+ if (owner) {
1237
+ var name = getComponentNameFromType(owner.type);
1238
+
1239
+ if (name) {
1240
+ info = '\n\nCheck the render method of `' + name + '`.';
1241
+ }
1242
+ }
1240
1243
 
1241
1244
  if (!info) {
1242
1245
  var parentName = getComponentNameFromType(parentType);
@@ -1249,31 +1252,6 @@ function getCurrentComponentErrorInfo(parentType) {
1249
1252
  return info;
1250
1253
  }
1251
1254
  }
1252
- /**
1253
- * Given a fragment, validate that it can only be provided with fragment props
1254
- * @param {ReactElement} fragment
1255
- */
1256
-
1257
-
1258
- function validateFragmentProps(fragment) {
1259
- // TODO: Move this to render phase instead of at element creation.
1260
- {
1261
- var keys = Object.keys(fragment.props);
1262
-
1263
- for (var i = 0; i < keys.length; i++) {
1264
- var key = keys[i];
1265
-
1266
- if (key !== 'children' && key !== 'key') {
1267
- setCurrentlyValidatingElement(fragment);
1268
-
1269
- error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
1270
-
1271
- setCurrentlyValidatingElement(null);
1272
- break;
1273
- }
1274
- }
1275
- }
1276
- }
1277
1255
 
1278
1256
  var jsxDEV = jsxDEV$1 ;
1279
1257
 
@@ -88,23 +88,36 @@ 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();
91
+ var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n';
92
92
 
93
- if (stack !== '') {
94
- format += '%s';
95
- args = args.concat([stack]);
96
- } // eslint-disable-next-line react-internal/safe-string-coercion
93
+ if (ReactSharedInternalsServer.getCurrentStack) {
94
+ var stack = ReactSharedInternalsServer.getCurrentStack();
97
95
 
96
+ if (stack !== '') {
97
+ format += '%s';
98
+ args = args.concat([stack]);
99
+ }
100
+ }
98
101
 
99
- var argsWithFormat = args.map(function (item) {
100
- return String(item);
101
- }); // Careful: RN currently depends on this prefix
102
-
103
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
102
+ if (isErrorLogger) {
103
+ // Don't prefix our default logging formatting in ReactFiberErrorLoggger.
104
+ // Don't toString the arguments.
105
+ args.unshift(format);
106
+ } else {
107
+ // TODO: Remove this prefix and stop toStringing in the wrapper and
108
+ // instead do it at each callsite as needed.
109
+ // Careful: RN currently depends on this prefix
110
+ // eslint-disable-next-line react-internal/safe-string-coercion
111
+ args = args.map(function (item) {
112
+ return String(item);
113
+ });
114
+ args.unshift('Warning: ' + format);
115
+ } // We intentionally don't use spread (or .apply) directly because it
104
116
  // breaks IE9: https://github.com/facebook/react/issues/13610
105
117
  // eslint-disable-next-line react-internal/no-production-logging
106
118
 
107
- Function.prototype.apply.call(console[level], console, argsWithFormat);
119
+
120
+ Function.prototype.apply.call(console[level], console, args);
108
121
  }
109
122
  }
110
123
 
@@ -295,7 +308,9 @@ function checkKeyStringCoercion(value) {
295
308
  }
296
309
  }
297
310
 
298
- var REACT_CLIENT_REFERENCE$1 = Symbol.for('react.client.reference');
311
+ 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.
312
+ // TODO: Delete this when enableOwnerStacks ships.
313
+
299
314
  function isValidElementType(type) {
300
315
  if (typeof type === 'string' || typeof type === 'function') {
301
316
  return true;
@@ -693,7 +708,8 @@ function describeFunctionComponentFrame(fn) {
693
708
  function shouldConstruct(Component) {
694
709
  var prototype = Component.prototype;
695
710
  return !!(prototype && prototype.isReactComponent);
696
- }
711
+ } // TODO: Delete this once the key warning no longer uses it. I.e. when enableOwnerStacks ship.
712
+
697
713
 
698
714
  function describeUnknownElementTypeFrameInDEV(type) {
699
715
 
@@ -924,7 +940,7 @@ function ReactElement(type, key, _ref, self, source, owner, props, debugStack, d
924
940
  configurable: false,
925
941
  enumerable: false,
926
942
  writable: true,
927
- value: false
943
+ value: 0
928
944
  }); // debugInfo contains Server Component debug information.
929
945
 
930
946
  Object.defineProperty(element, '_debugInfo', {
@@ -1109,29 +1125,7 @@ function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) {
1109
1125
  }
1110
1126
  }
1111
1127
 
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 '';
1128
+ return ReactElement(type, key, ref, self, source, getOwner(), props);
1135
1129
  }
1136
1130
  }
1137
1131
  /**
@@ -1144,7 +1138,6 @@ function getDeclarationErrorAddendum() {
1144
1138
  * @param {*} parentType node's parent's type.
1145
1139
  */
1146
1140
 
1147
-
1148
1141
  function validateChildKeys(node, parentType) {
1149
1142
  {
1150
1143
  if (typeof node !== 'object' || !node) {
@@ -1162,7 +1155,7 @@ function validateChildKeys(node, parentType) {
1162
1155
  } else if (isValidElement(node)) {
1163
1156
  // This element was passed in a valid location.
1164
1157
  if (node._store) {
1165
- node._store.validated = true;
1158
+ node._store.validated = 1;
1166
1159
  }
1167
1160
  } else {
1168
1161
  var iteratorFn = getIteratorFn(node);
@@ -1213,12 +1206,13 @@ var ownerHasKeyUseWarning = {};
1213
1206
  */
1214
1207
 
1215
1208
  function validateExplicitKey(element, parentType) {
1209
+
1216
1210
  {
1217
1211
  if (!element._store || element._store.validated || element.key != null) {
1218
1212
  return;
1219
1213
  }
1220
1214
 
1221
- element._store.validated = true;
1215
+ element._store.validated = 1;
1222
1216
  var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1223
1217
 
1224
1218
  if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
@@ -1244,28 +1238,37 @@ function validateExplicitKey(element, parentType) {
1244
1238
  childOwner = " It was passed a child from " + ownerName + ".";
1245
1239
  }
1246
1240
 
1247
- setCurrentlyValidatingElement(element);
1241
+ var prevGetCurrentStack = ReactSharedInternalsServer.getCurrentStack;
1248
1242
 
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);
1243
+ ReactSharedInternalsServer.getCurrentStack = function () {
1250
1244
 
1251
- setCurrentlyValidatingElement(null);
1252
- }
1253
- }
1245
+ var stack = describeUnknownElementTypeFrameInDEV(element.type); // Delegate to the injected renderer-specific implementation
1254
1246
 
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
- }
1247
+ if (prevGetCurrentStack) {
1248
+ stack += prevGetCurrentStack() || '';
1249
+ }
1250
+
1251
+ return stack;
1252
+ };
1253
+
1254
+ 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);
1255
+
1256
+ ReactSharedInternalsServer.getCurrentStack = prevGetCurrentStack;
1263
1257
  }
1264
1258
  }
1265
1259
 
1266
1260
  function getCurrentComponentErrorInfo(parentType) {
1267
1261
  {
1268
- var info = getDeclarationErrorAddendum();
1262
+ var info = '';
1263
+ var owner = getOwner();
1264
+
1265
+ if (owner) {
1266
+ var name = getComponentNameFromType(owner.type);
1267
+
1268
+ if (name) {
1269
+ info = '\n\nCheck the render method of `' + name + '`.';
1270
+ }
1271
+ }
1269
1272
 
1270
1273
  if (!info) {
1271
1274
  var parentName = getComponentNameFromType(parentType);
@@ -1278,31 +1281,6 @@ function getCurrentComponentErrorInfo(parentType) {
1278
1281
  return info;
1279
1282
  }
1280
1283
  }
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
1284
 
1307
1285
  var jsx = jsxProdSignatureRunningInDevWithDynamicChildren ; // we may want to special case jsxs internally to take advantage of static children.
1308
1286
  // for now we can ship identical prod functions