|
7 | 7 | * @noflow |
8 | 8 | * @nolint |
9 | 9 | * @preventMunge |
10 | | - * @generated SignedSource<<98724556db7e01bfefca7439ac7adfc3>> |
| 10 | + * @generated SignedSource<<3f7c609322e65db1e2ce38a0f7c72577>> |
11 | 11 | */ |
12 | 12 |
|
13 | 13 | 'use strict'; |
@@ -55,11 +55,14 @@ function printWarning(level, format, args) { |
55 | 55 | // update consoleWithStackDev.www.js as well. |
56 | 56 | { |
57 | 57 | var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n'; |
58 | | - var stack = ReactSharedInternals.getStackAddendum(); |
59 | 58 |
|
60 | | - if (stack !== '') { |
61 | | - format += '%s'; |
62 | | - args = args.concat([stack]); |
| 59 | + if (ReactSharedInternals.getCurrentStack) { |
| 60 | + var stack = ReactSharedInternals.getCurrentStack(); |
| 61 | + |
| 62 | + if (stack !== '') { |
| 63 | + format += '%s'; |
| 64 | + args = args.concat([stack]); |
| 65 | + } |
63 | 66 | } |
64 | 67 |
|
65 | 68 | if (isErrorLogger) { |
@@ -5631,7 +5634,7 @@ var warnForMissingKey = function (child, returnFiber) {}; |
5631 | 5634 | return; |
5632 | 5635 | } |
5633 | 5636 |
|
5634 | | - if (!child._store || child._store.validated || child.key != null) { |
| 5637 | + if (!child._store || (child._store.validated || child.key != null) && child._store.validated !== 2) { |
5635 | 5638 | return; |
5636 | 5639 | } |
5637 | 5640 |
|
@@ -5640,17 +5643,96 @@ var warnForMissingKey = function (child, returnFiber) {}; |
5640 | 5643 | } // $FlowFixMe[cannot-write] unable to narrow type from mixed to writable object |
5641 | 5644 |
|
5642 | 5645 |
|
5643 | | - child._store.validated = true; |
5644 | | - var componentName = getComponentNameFromFiber(returnFiber) || 'Component'; |
| 5646 | + child._store.validated = 1; |
| 5647 | + var componentName = getComponentNameFromFiber(returnFiber); |
| 5648 | + var componentKey = componentName || 'null'; |
5645 | 5649 |
|
5646 | | - if (ownerHasKeyUseWarning[componentName]) { |
| 5650 | + if (ownerHasKeyUseWarning[componentKey]) { |
5647 | 5651 | return; |
5648 | 5652 | } |
5649 | 5653 |
|
5650 | | - ownerHasKeyUseWarning[componentName] = true; |
| 5654 | + ownerHasKeyUseWarning[componentKey] = true; |
| 5655 | + var childOwner = child._owner; |
| 5656 | + var parentOwner = returnFiber._debugOwner; |
| 5657 | + var currentComponentErrorInfo = ''; |
| 5658 | + |
| 5659 | + if (parentOwner && typeof parentOwner.tag === 'number') { |
| 5660 | + var name = getComponentNameFromFiber(parentOwner); |
| 5661 | + |
| 5662 | + if (name) { |
| 5663 | + currentComponentErrorInfo = '\n\nCheck the render method of `' + name + '`.'; |
| 5664 | + } |
| 5665 | + } |
| 5666 | + |
| 5667 | + if (!currentComponentErrorInfo) { |
| 5668 | + if (componentName) { |
| 5669 | + currentComponentErrorInfo = "\n\nCheck the top-level render call using <" + componentName + ">."; |
| 5670 | + } |
| 5671 | + } // Usually the current owner is the offender, but if it accepts children as a |
| 5672 | + // property, it may be the creator of the child that's responsible for |
| 5673 | + // assigning it a key. |
| 5674 | + |
| 5675 | + |
| 5676 | + var childOwnerAppendix = ''; |
| 5677 | + |
| 5678 | + if (childOwner != null && parentOwner !== childOwner) { |
| 5679 | + var ownerName = null; |
| 5680 | + |
| 5681 | + if (typeof childOwner.tag === 'number') { |
| 5682 | + ownerName = getComponentNameFromFiber(childOwner); |
| 5683 | + } else if (typeof childOwner.name === 'string') { |
| 5684 | + ownerName = childOwner.name; |
| 5685 | + } |
| 5686 | + |
| 5687 | + if (ownerName) { |
| 5688 | + // Give the component that originally created this child. |
| 5689 | + childOwnerAppendix = " It was passed a child from " + ownerName + "."; |
| 5690 | + } |
| 5691 | + } // We create a fake Fiber for the child to log the stack trace from. |
| 5692 | + // TODO: Refactor the warnForMissingKey calls to happen after fiber creation |
| 5693 | + // so that we can get access to the fiber that will eventually be created. |
| 5694 | + // That way the log can show up associated with the right instance in DevTools. |
| 5695 | + |
| 5696 | + |
| 5697 | + var fiber = createFiberFromElement(child, returnFiber.mode, 0); |
| 5698 | + fiber.return = returnFiber; |
| 5699 | + var prevDebugFiber = getCurrentFiber(); |
| 5700 | + setCurrentFiber(fiber); |
| 5701 | + |
| 5702 | + 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, childOwnerAppendix); |
5651 | 5703 |
|
5652 | | - error('Each child in a list should have a unique ' + '"key" prop. See https://react.dev/link/warning-keys for ' + 'more information.'); |
| 5704 | + setCurrentFiber(prevDebugFiber); |
5653 | 5705 | }; |
| 5706 | +} // Given a fragment, validate that it can only be provided with fragment props |
| 5707 | +// We do this here instead of BeginWork because the Fragment fiber doesn't have |
| 5708 | +// the whole props object, only the children and is shared with arrays. |
| 5709 | + |
| 5710 | + |
| 5711 | +function validateFragmentProps(element, fiber, returnFiber) { |
| 5712 | + { |
| 5713 | + var keys = Object.keys(element.props); |
| 5714 | + |
| 5715 | + for (var i = 0; i < keys.length; i++) { |
| 5716 | + var key = keys[i]; |
| 5717 | + |
| 5718 | + if (key !== 'children' && key !== 'key') { |
| 5719 | + if (fiber === null) { |
| 5720 | + // For unkeyed root fragments there's no Fiber. We create a fake one just for |
| 5721 | + // error stack handling. |
| 5722 | + fiber = createFiberFromElement(element, returnFiber.mode, 0); |
| 5723 | + fiber.return = returnFiber; |
| 5724 | + } |
| 5725 | + |
| 5726 | + var prevDebugFiber = getCurrentFiber(); |
| 5727 | + setCurrentFiber(fiber); |
| 5728 | + |
| 5729 | + error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); |
| 5730 | + |
| 5731 | + setCurrentFiber(prevDebugFiber); |
| 5732 | + break; |
| 5733 | + } |
| 5734 | + } |
| 5735 | + } |
5654 | 5736 | } |
5655 | 5737 |
|
5656 | 5738 | function unwrapThenable(thenable) { |
@@ -5871,7 +5953,9 @@ function createChildReconciler(shouldTrackSideEffects) { |
5871 | 5953 | var elementType = element.type; |
5872 | 5954 |
|
5873 | 5955 | if (elementType === REACT_FRAGMENT_TYPE) { |
5874 | | - return updateFragment(returnFiber, current, element.props.children, lanes, element.key, debugInfo); |
| 5956 | + var updated = updateFragment(returnFiber, current, element.props.children, lanes, element.key, debugInfo); |
| 5957 | + validateFragmentProps(element, updated, returnFiber); |
| 5958 | + return updated; |
5875 | 5959 | } |
5876 | 5960 |
|
5877 | 5961 | if (current !== null) { |
@@ -6615,6 +6699,7 @@ function createChildReconciler(shouldTrackSideEffects) { |
6615 | 6699 | existing._debugInfo = debugInfo; |
6616 | 6700 | } |
6617 | 6701 |
|
| 6702 | + validateFragmentProps(element, existing, returnFiber); |
6618 | 6703 | return existing; |
6619 | 6704 | } |
6620 | 6705 | } else { |
@@ -6658,6 +6743,7 @@ function createChildReconciler(shouldTrackSideEffects) { |
6658 | 6743 | created._debugInfo = debugInfo; |
6659 | 6744 | } |
6660 | 6745 |
|
| 6746 | + validateFragmentProps(element, created, returnFiber); |
6661 | 6747 | return created; |
6662 | 6748 | } else { |
6663 | 6749 | var _created4 = createFiberFromElement(element, returnFiber.mode, lanes); |
@@ -6720,6 +6806,7 @@ function createChildReconciler(shouldTrackSideEffects) { |
6720 | 6806 | var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null; |
6721 | 6807 |
|
6722 | 6808 | if (isUnkeyedTopLevelFragment) { |
| 6809 | + validateFragmentProps(newChild, null, returnFiber); |
6723 | 6810 | newChild = newChild.props.children; |
6724 | 6811 | } // Handle object types |
6725 | 6812 |
|
@@ -23122,10 +23209,22 @@ key, pendingProps, owner, mode, lanes) { |
23122 | 23209 | } |
23123 | 23210 |
|
23124 | 23211 | var info = ''; |
| 23212 | + var typeString; |
23125 | 23213 |
|
23126 | 23214 | { |
23127 | 23215 | if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { |
23128 | | - info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and " + 'named imports.'; |
| 23216 | + info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports."; |
| 23217 | + } |
| 23218 | + |
| 23219 | + if (type === null) { |
| 23220 | + typeString = 'null'; |
| 23221 | + } else if (isArray(type)) { |
| 23222 | + typeString = 'array'; |
| 23223 | + } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { |
| 23224 | + typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />"; |
| 23225 | + info = ' Did you accidentally export a JSX literal instead of a component?'; |
| 23226 | + } else { |
| 23227 | + typeString = typeof type; |
23129 | 23228 | } |
23130 | 23229 |
|
23131 | 23230 | var ownerName = owner ? getComponentNameFromOwner(owner) : null; |
@@ -23135,7 +23234,7 @@ key, pendingProps, owner, mode, lanes) { |
23135 | 23234 | } |
23136 | 23235 | } |
23137 | 23236 |
|
23138 | | - throw new Error('Element type is invalid: expected a string (for built-in ' + 'components) or a class/function (for composite components) ' + ("but got: " + (type == null ? type : typeof type) + "." + info)); |
| 23237 | + throw new Error('Element type is invalid: expected a string (for built-in ' + 'components) or a class/function (for composite components) ' + ("but got: " + typeString + "." + info)); |
23139 | 23238 | } |
23140 | 23239 | } |
23141 | 23240 | } |
@@ -23344,7 +23443,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition |
23344 | 23443 | return root; |
23345 | 23444 | } |
23346 | 23445 |
|
23347 | | -var ReactVersion = '19.0.0-rc-47384982'; |
| 23446 | +var ReactVersion = '19.0.0-rc-c6122275'; |
23348 | 23447 |
|
23349 | 23448 | /* |
23350 | 23449 | * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol |
|