GeezerVison is showing github.com — Remove unused arguments from ReactElement (#34174) · react/react@1dc3bde
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react/src/jsx/ReactJSXElement.js +13-71Lines changed: 13 additions & 71 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -156,30 +156,9 @@ function elementRefGetterWithDeprecationWarning() { | 156 | 156 | * will not work. Instead test $$typeof field against Symbol.for('react.transitional.element') to check | 157 | 157 | * if something is a React Element. | 158 | 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. | 171 | 159 | * @internal | 172 | 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) { | 183 | 162 | // Ignore whatever was passed as the ref argument and treat `props.ref` as | 184 | 163 | // the source of truth. The only thing we use this for is `element.ref`, | 185 | 164 | // which will log a deprecation warning on access. In the next release, we | @@ -348,16 +327,7 @@ export function jsxProd(type, config, maybeKey) { | 348 | 327 | } | 349 | 328 | } | 350 | 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); | 361 | 331 | } | 362 | 332 |
| 363 | 333 | // While `jsxDEV` should never be called when running in production, we do | @@ -376,8 +346,6 @@ export function jsxProdSignatureRunningInDevWithDynamicChildren( | 376 | 346 | type, | 377 | 347 | config, | 378 | 348 | maybeKey, | 379 | | - source, | 380 | | - self, | 381 | 349 | ) { | 382 | 350 | if (__DEV__) { | 383 | 351 | const isStaticChildren = false; | @@ -389,8 +357,6 @@ export function jsxProdSignatureRunningInDevWithDynamicChildren( | 389 | 357 | config, | 390 | 358 | maybeKey, | 391 | 359 | isStaticChildren, | 392 | | - source, | 393 | | - self, | 394 | 360 | __DEV__ && | 395 | 361 | (trackActualOwner | 396 | 362 | ? Error('react-stack-top-frame') | @@ -407,8 +373,6 @@ export function jsxProdSignatureRunningInDevWithStaticChildren( | 407 | 373 | type, | 408 | 374 | config, | 409 | 375 | maybeKey, | 410 | | - source, | 411 | | - self, | 412 | 376 | ) { | 413 | 377 | if (__DEV__) { | 414 | 378 | const isStaticChildren = true; | @@ -420,8 +384,6 @@ export function jsxProdSignatureRunningInDevWithStaticChildren( | 420 | 384 | config, | 421 | 385 | maybeKey, | 422 | 386 | isStaticChildren, | 423 | | - source, | 424 | | - self, | 425 | 387 | __DEV__ && | 426 | 388 | (trackActualOwner | 427 | 389 | ? Error('react-stack-top-frame') | @@ -442,7 +404,7 @@ const didWarnAboutKeySpread = {}; | 442 | 404 | * @param {object} props | 443 | 405 | * @param {string} key | 444 | 406 | */ | 445 | | -export function jsxDEV(type, config, maybeKey, isStaticChildren, source, self) { | | 407 | +export function jsxDEV(type, config, maybeKey, isStaticChildren) { | 446 | 408 | const trackActualOwner = | 447 | 409 | __DEV__ && | 448 | 410 | ReactSharedInternals.recentlyCreatedOwnerStacks++ < ownerStackLimit; | @@ -451,8 +413,6 @@ export function jsxDEV(type, config, maybeKey, isStaticChildren, source, self) { | 451 | 413 | config, | 452 | 414 | maybeKey, | 453 | 415 | isStaticChildren, | 454 | | - source, | 455 | | - self, | 456 | 416 | __DEV__ && | 457 | 417 | (trackActualOwner | 458 | 418 | ? Error('react-stack-top-frame') | @@ -469,8 +429,6 @@ function jsxDEVImpl( | 469 | 429 | config, | 470 | 430 | maybeKey, | 471 | 431 | isStaticChildren, | 472 | | - source, | 473 | | - self, | 474 | 432 | debugStack, | 475 | 433 | debugTask, | 476 | 434 | ) { | @@ -491,7 +449,7 @@ function jsxDEVImpl( | 491 | 449 | if (isStaticChildren) { | 492 | 450 | if (isArray(children)) { | 493 | 451 | for (let i = 0; i < children.length; i++) { | 494 | | - validateChildKeys(children[i], type); | | 452 | + validateChildKeys(children[i]); | 495 | 453 | } | 496 | 454 |
| 497 | 455 | if (Object.freeze) { | @@ -505,7 +463,7 @@ function jsxDEVImpl( | 505 | 463 | ); | 506 | 464 | } | 507 | 465 | } else { | 508 | | - validateChildKeys(children, type); | | 466 | + validateChildKeys(children); | 509 | 467 | } | 510 | 468 | } | 511 | 469 |
| @@ -591,16 +549,7 @@ function jsxDEVImpl( | 591 | 549 | defineKeyPropWarningGetter(props, displayName); | 592 | 550 | } | 593 | 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); | 604 | 553 | } | 605 | 554 | } | 606 | 555 |
| @@ -620,7 +569,7 @@ export function createElement(type, config, children) { | 620 | 569 | // prod. (Rendering will throw with a helpful message and as soon as the | 621 | 570 | // type is fixed, the key warnings will appear.) | 622 | 571 | for (let i = 2; i < arguments.length; i++) { | 623 | | - validateChildKeys(arguments[i], type); | | 572 | + validateChildKeys(arguments[i]); | 624 | 573 | } | 625 | 574 |
| 626 | 575 | // Unlike the jsx() runtime, createElement() doesn't warn about key spread. | @@ -721,10 +670,8 @@ export function createElement(type, config, children) { | 721 | 670 | return ReactElement( | 722 | 671 | type, | 723 | 672 | key, | 724 | | - undefined, | 725 | | - undefined, | 726 | | - getOwner(), | 727 | 673 | props, | | 674 | + getOwner(), | 728 | 675 | __DEV__ && | 729 | 676 | (trackActualOwner | 730 | 677 | ? Error('react-stack-top-frame') | @@ -740,10 +687,8 @@ export function cloneAndReplaceKey(oldElement, newKey) { | 740 | 687 | const clonedElement = ReactElement( | 741 | 688 | oldElement.type, | 742 | 689 | newKey, | 743 | | - undefined, | 744 | | - undefined, | 745 | | - !__DEV__ ? undefined : oldElement._owner, | 746 | 690 | oldElement.props, | | 691 | + !__DEV__ ? undefined : oldElement._owner, | 747 | 692 | __DEV__ && oldElement._debugStack, | 748 | 693 | __DEV__ && oldElement._debugTask, | 749 | 694 | ); | @@ -829,16 +774,14 @@ export function cloneElement(element, config, children) { | 829 | 774 | const clonedElement = ReactElement( | 830 | 775 | element.type, | 831 | 776 | key, | 832 | | - undefined, | 833 | | - undefined, | 834 | | - owner, | 835 | 777 | props, | | 778 | + owner, | 836 | 779 | __DEV__ && element._debugStack, | 837 | 780 | __DEV__ && element._debugTask, | 838 | 781 | ); | 839 | 782 |
| 840 | 783 | for (let i = 2; i < arguments.length; i++) { | 841 | | - validateChildKeys(arguments[i], clonedElement.type); | | 784 | + validateChildKeys(arguments[i]); | 842 | 785 | } | 843 | 786 |
| 844 | 787 | return clonedElement; | @@ -853,10 +796,9 @@ export function cloneElement(element, config, children) { | 853 | 796 | * @param {ReactNode} node Statically passed child of any type. | 854 | 797 | * @param {*} parentType node's parent's type. | 855 | 798 | */ | 856 | | -function validateChildKeys(node, parentType) { | | 799 | +function validateChildKeys(node) { | 857 | 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 | 860 | 802 | // don't need keys. | 861 | 803 | if (isValidElement(node)) { | 862 | 804 | if (node._store) { | |
|