Remove unused arguments from ReactElement (#34174)
After various feature flag removals recently, these arguments became unused and can be deleted.
Jan Kassens committed
Aug 12, 2025 at 11:09 UTC
1dc3bdead16bfb6d481f29b4ec55ffcf63f5bca8
1 file changed
+13
-71
packages/react/src/jsx/ReactJSXElement.js
+13
-71
@@ -156,30 +156,9 @@ function elementRefGetterWithDeprecationWarning() {
156
* will not work. Instead test $$typeof field against Symbol.for('react.transitional.element') to check
157
* if something is a React Element.
158
*
159
- * @param {*} type
160
- * @param {*} props
161
- * @param {*} key
162
- * @param {string|object} ref
163
- * @param {*} owner
164
- * @param {*} self A *temporary* helper to detect places where `this` is
165
- * different from the `owner` when React.createElement is called, so that we
166
- * can warn. We want to get rid of owner and replace string `ref`s with arrow
167
- * functions, and as long as `this` and owner are the same, there will be no
168
- * change in behavior.
169
- * @param {*} source An annotation object (added by a transpiler or otherwise)
170
- * indicating filename, line number, and/or other information.
159
* @internal
160
*/
173
-function ReactElement(
174
- type,
175
- key,
176
- self,
177
- source,
178
- owner,
179
- props,
180
- debugStack,
181
- debugTask,
182
-) {
161
+function ReactElement(type, key, props, owner, debugStack, debugTask) {
162
// Ignore whatever was passed as the ref argument and treat `props.ref` as
163
// the source of truth. The only thing we use this for is `element.ref`,
164
// which will log a deprecation warning on access. In the next release, we
@@ -348,16 +327,7 @@ export function jsxProd(type, config, maybeKey) {
327
}
328
}
329
351
- return ReactElement(
352
- type,
353
- key,
354
- undefined,
355
- undefined,
356
- getOwner(),
357
- props,
358
- undefined,
359
- undefined,
360
- );
330
+ return ReactElement(type, key, props, getOwner(), undefined, undefined);
331
}
332
333
// While `jsxDEV` should never be called when running in production, we do
@@ -376,8 +346,6 @@ export function jsxProdSignatureRunningInDevWithDynamicChildren(
346
type,
347
config,
348
maybeKey,
379
- source,
380
- self,
349
) {
350
if (__DEV__) {
351
const isStaticChildren = false;
@@ -389,8 +357,6 @@ export function jsxProdSignatureRunningInDevWithDynamicChildren(
357
config,
358
maybeKey,
359
isStaticChildren,
392
- source,
393
- self,
360
__DEV__ &&
361
(trackActualOwner
362
? Error('react-stack-top-frame')
@@ -407,8 +373,6 @@ export function jsxProdSignatureRunningInDevWithStaticChildren(
373
type,
374
config,
375
maybeKey,
410
- source,
411
- self,
376
) {
377
if (__DEV__) {
378
const isStaticChildren = true;
@@ -420,8 +384,6 @@ export function jsxProdSignatureRunningInDevWithStaticChildren(
384
config,
385
maybeKey,
386
isStaticChildren,
423
- source,
424
- self,
387
__DEV__ &&
388
(trackActualOwner
389
? Error('react-stack-top-frame')
@@ -442,7 +404,7 @@ const didWarnAboutKeySpread = {};
404
* @param {object} props
405
* @param {string} key
406
*/
445
-export function jsxDEV(type, config, maybeKey, isStaticChildren, source, self) {
407
+export function jsxDEV(type, config, maybeKey, isStaticChildren) {
408
const trackActualOwner =
409
__DEV__ &&
410
ReactSharedInternals.recentlyCreatedOwnerStacks++ < ownerStackLimit;
@@ -451,8 +413,6 @@ export function jsxDEV(type, config, maybeKey, isStaticChildren, source, self) {
413
config,
414
maybeKey,
415
isStaticChildren,
454
- source,
455
- self,
416
__DEV__ &&
417
(trackActualOwner
418
? Error('react-stack-top-frame')
@@ -469,8 +429,6 @@ function jsxDEVImpl(
429
config,
430
maybeKey,
431
isStaticChildren,
472
- source,
473
- self,
432
debugStack,
433
debugTask,
434
) {
@@ -491,7 +449,7 @@ function jsxDEVImpl(
449
if (isStaticChildren) {
450
if (isArray(children)) {
451
for (let i = 0; i < children.length; i++) {
494
- validateChildKeys(children[i], type);
452
+ validateChildKeys(children[i]);
453
}
454
455
if (Object.freeze) {
@@ -505,7 +463,7 @@ function jsxDEVImpl(
463
);
464
}
465
} else {
508
- validateChildKeys(children, type);
466
+ validateChildKeys(children);
467
}
468
}
469
@@ -591,16 +549,7 @@ function jsxDEVImpl(
549
defineKeyPropWarningGetter(props, displayName);
550
}
551
594
- return ReactElement(
595
- type,
596
- key,
597
- self,
598
- source,
599
- getOwner(),
600
- props,
601
- debugStack,
602
- debugTask,
603
- );
552
+ return ReactElement(type, key, props, getOwner(), debugStack, debugTask);
553
}
554
}
555
@@ -620,7 +569,7 @@ export function createElement(type, config, children) {
569
// prod. (Rendering will throw with a helpful message and as soon as the
570
// type is fixed, the key warnings will appear.)
571
for (let i = 2; i < arguments.length; i++) {
623
- validateChildKeys(arguments[i], type);
572
+ validateChildKeys(arguments[i]);
573
}
574
575
// Unlike the jsx() runtime, createElement() doesn't warn about key spread.
@@ -721,10 +670,8 @@ export function createElement(type, config, children) {
670
return ReactElement(
671
type,
672
key,
724
- undefined,
725
- undefined,
726
- getOwner(),
673
props,
674
+ getOwner(),
675
__DEV__ &&
676
(trackActualOwner
677
? Error('react-stack-top-frame')
@@ -740,10 +687,8 @@ export function cloneAndReplaceKey(oldElement, newKey) {
687
const clonedElement = ReactElement(
688
oldElement.type,
689
newKey,
743
- undefined,
744
- undefined,
745
- !__DEV__ ? undefined : oldElement._owner,
690
oldElement.props,
691
+ !__DEV__ ? undefined : oldElement._owner,
692
__DEV__ && oldElement._debugStack,
693
__DEV__ && oldElement._debugTask,
694
);
@@ -829,16 +774,14 @@ export function cloneElement(element, config, children) {
774
const clonedElement = ReactElement(
775
element.type,
776
key,
832
- undefined,
833
- undefined,
834
- owner,
777
props,
778
+ owner,
779
__DEV__ && element._debugStack,
780
__DEV__ && element._debugTask,
781
);
782
783
for (let i = 2; i < arguments.length; i++) {
841
- validateChildKeys(arguments[i], clonedElement.type);
784
+ validateChildKeys(arguments[i]);
785
}
786
787
return clonedElement;
@@ -853,10 +796,9 @@ export function cloneElement(element, config, children) {
796
* @param {ReactNode} node Statically passed child of any type.
797
* @param {*} parentType node's parent's type.
798
*/
856
-function validateChildKeys(node, parentType) {
799
+function validateChildKeys(node) {
800
if (__DEV__) {
858
- // With owner stacks is, no warnings happens. All we do is
859
- // mark elements as being in a valid static child position so they
801
+ // Mark elements as being in a valid static child position so they
802
// don't need keys.
803
if (isValidElement(node)) {
804
if (node._store) {