Skip to content

Commit 8d18ce3

Browse files
authored
Merge pull request #49405 from gijoe0295/gijoe/49064
fix: a props object containing `key` prop is spread into jsx
2 parents 6b99d02 + 6b71989 commit 8d18ce3

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/components/Form/InputWrapper.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,16 @@ function InputWrapper<TInput extends ValidInputs, TValue extends ValueTypeKey>(p
7676
const {registerInput} = useContext(FormContext);
7777

7878
const {shouldSetTouchedOnBlurOnly, blurOnSubmit, shouldSubmitForm} = computeComponentSpecificRegistrationParams(props as InputComponentBaseProps);
79+
const {key, ...registerInputProps} = registerInput(inputID, shouldSubmitForm, {ref, valueType, ...rest, shouldSetTouchedOnBlurOnly, blurOnSubmit});
7980

80-
// TODO: Sometimes we return too many props with register input, so we need to consider if it's better to make the returned type more general and disregard the issue, or we would like to omit the unused props somehow.
81-
// eslint-disable-next-line react/jsx-props-no-spreading
82-
return <InputComponent {...registerInput(inputID, shouldSubmitForm, {ref, valueType, ...rest, shouldSetTouchedOnBlurOnly, blurOnSubmit})} />;
81+
return (
82+
<InputComponent
83+
key={key}
84+
// TODO: Sometimes we return too many props with register input, so we need to consider if it's better to make the returned type more general and disregard the issue, or we would like to omit the unused props somehow.
85+
// eslint-disable-next-line react/jsx-props-no-spreading
86+
{...registerInputProps}
87+
/>
88+
);
8389
}
8490

8591
InputWrapper.displayName = 'InputWrapper';

src/components/MenuItemList.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@ function MenuItemList({
8282

8383
return (
8484
<>
85-
{menuItems.map((menuItemProps) => (
85+
{menuItems.map(({key, ...menuItemProps}) => (
8686
<OfflineWithFeedback
87-
key={menuItemProps.key ?? menuItemProps.title}
87+
key={key ?? menuItemProps.title}
8888
pendingAction={menuItemProps.pendingAction}
8989
onClose={menuItemProps.onPendingActionDismiss}
9090
errors={menuItemProps.error}
9191
shouldForceOpacity={menuItemProps.shouldForceOpacity}
9292
>
9393
<MenuItem
94-
key={menuItemProps.key ?? menuItemProps.title}
94+
key={key ?? menuItemProps.title}
9595
wrapperStyle={wrapperStyle}
9696
onSecondaryInteraction={menuItemProps.link !== undefined ? (e) => secondaryInteraction(menuItemProps.link, e) : undefined}
9797
ref={popoverAnchor}

0 commit comments

Comments
 (0)