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.
@@ -28,29 +28,45 @@ function error(format) {
28
28
  printWarning('error', format, args);
29
29
  }
30
30
  }
31
- }
31
+ } // eslint-disable-next-line react-internal/no-production-logging
32
32
 
33
33
  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();
38
-
39
- if (stack !== '') {
40
- format += '%s';
41
- args = args.concat([stack]);
42
- } // eslint-disable-next-line react-internal/safe-string-coercion
37
+ var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n';
43
38
 
39
+ if (ReactSharedInternals.getCurrentStack) {
40
+ // We only add the current stack to the console when createTask is not supported.
41
+ // Since createTask requires DevTools to be open to work, this means that stacks
42
+ // can be lost while DevTools isn't open but we can't detect this.
43
+ var stack = ReactSharedInternals.getCurrentStack();
44
44
 
45
- var argsWithFormat = args.map(function (item) {
46
- return String(item);
47
- }); // Careful: RN currently depends on this prefix
45
+ if (stack !== '') {
46
+ format += '%s';
47
+ args = args.concat([stack]);
48
+ }
49
+ }
48
50
 
49
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
51
+ if (isErrorLogger) {
52
+ // Don't prefix our default logging formatting in ReactFiberErrorLoggger.
53
+ // Don't toString the arguments.
54
+ args.unshift(format);
55
+ } else {
56
+ // TODO: Remove this prefix and stop toStringing in the wrapper and
57
+ // instead do it at each callsite as needed.
58
+ // Careful: RN currently depends on this prefix
59
+ // eslint-disable-next-line react-internal/safe-string-coercion
60
+ args = args.map(function (item) {
61
+ return String(item);
62
+ });
63
+ args.unshift('Warning: ' + format);
64
+ } // We intentionally don't use spread (or .apply) directly because it
50
65
  // breaks IE9: https://github.com/facebook/react/issues/13610
51
66
  // eslint-disable-next-line react-internal/no-production-logging
52
67
 
53
- Function.prototype.apply.call(console[level], console, argsWithFormat);
68
+
69
+ Function.prototype.apply.call(console[level], console, args);
54
70
  }
55
71
  }
56
72
 
@@ -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', {
@@ -946,6 +965,10 @@ var didWarnAboutKeySpread = {};
946
965
  */
947
966
 
948
967
  function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) {
968
+ return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self);
969
+ }
970
+
971
+ function jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self, debugStack, debugTask) {
949
972
  {
950
973
  if (!isValidElementType(type)) {
951
974
  // This is an invalid element type.
@@ -1080,29 +1103,7 @@ function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) {
1080
1103
  }
1081
1104
  }
1082
1105
 
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 '';
1106
+ return ReactElement(type, key, ref, self, source, getOwner(), props);
1106
1107
  }
1107
1108
  }
1108
1109
  /**
@@ -1115,7 +1116,6 @@ function getDeclarationErrorAddendum() {
1115
1116
  * @param {*} parentType node's parent's type.
1116
1117
  */
1117
1118
 
1118
-
1119
1119
  function validateChildKeys(node, parentType) {
1120
1120
  {
1121
1121
  if (typeof node !== 'object' || !node) {
@@ -1133,7 +1133,7 @@ function validateChildKeys(node, parentType) {
1133
1133
  } else if (isValidElement(node)) {
1134
1134
  // This element was passed in a valid location.
1135
1135
  if (node._store) {
1136
- node._store.validated = true;
1136
+ node._store.validated = 1;
1137
1137
  }
1138
1138
  } else {
1139
1139
  var iteratorFn = getIteratorFn(node);
@@ -1184,12 +1184,13 @@ var ownerHasKeyUseWarning = {};
1184
1184
  */
1185
1185
 
1186
1186
  function validateExplicitKey(element, parentType) {
1187
+
1187
1188
  {
1188
1189
  if (!element._store || element._store.validated || element.key != null) {
1189
1190
  return;
1190
1191
  }
1191
1192
 
1192
- element._store.validated = true;
1193
+ element._store.validated = 1;
1193
1194
  var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1194
1195
 
1195
1196
  if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
@@ -1215,28 +1216,37 @@ function validateExplicitKey(element, parentType) {
1215
1216
  childOwner = " It was passed a child from " + ownerName + ".";
1216
1217
  }
1217
1218
 
1218
- setCurrentlyValidatingElement(element);
1219
+ var prevGetCurrentStack = ReactSharedInternals.getCurrentStack;
1219
1220
 
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);
1221
+ ReactSharedInternals.getCurrentStack = function () {
1221
1222
 
1222
- setCurrentlyValidatingElement(null);
1223
- }
1224
- }
1223
+ var stack = describeUnknownElementTypeFrameInDEV(element.type); // Delegate to the injected renderer-specific implementation
1225
1224
 
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
- }
1225
+ if (prevGetCurrentStack) {
1226
+ stack += prevGetCurrentStack() || '';
1227
+ }
1228
+
1229
+ return stack;
1230
+ };
1231
+
1232
+ 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);
1233
+
1234
+ ReactSharedInternals.getCurrentStack = prevGetCurrentStack;
1234
1235
  }
1235
1236
  }
1236
1237
 
1237
1238
  function getCurrentComponentErrorInfo(parentType) {
1238
1239
  {
1239
- var info = getDeclarationErrorAddendum();
1240
+ var info = '';
1241
+ var owner = getOwner();
1242
+
1243
+ if (owner) {
1244
+ var name = getComponentNameFromType(owner.type);
1245
+
1246
+ if (name) {
1247
+ info = '\n\nCheck the render method of `' + name + '`.';
1248
+ }
1249
+ }
1240
1250
 
1241
1251
  if (!info) {
1242
1252
  var parentName = getComponentNameFromType(parentType);
@@ -1249,31 +1259,6 @@ function getCurrentComponentErrorInfo(parentType) {
1249
1259
  return info;
1250
1260
  }
1251
1261
  }
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
1262
 
1278
1263
  var jsxDEV = jsxDEV$1 ;
1279
1264
 
@@ -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