diff --git a/docs/data/material/components/autocomplete/CustomizedHook.js b/docs/data/material/components/autocomplete/CustomizedHook.js index 2d4b116616e83e..54dacedfde7591 100644 --- a/docs/data/material/components/autocomplete/CustomizedHook.js +++ b/docs/data/material/components/autocomplete/CustomizedHook.js @@ -181,20 +181,24 @@ export default function CustomizedHook() {
- {value.map((option, index) => ( - - ))} + {value.map((option, index) => { + const { key, ...tagProps } = getTagProps({ index }); + return ; + })}
{groupedOptions.length > 0 ? ( - {groupedOptions.map((option, index) => ( -
  • - {option.title} - -
  • - ))} + {groupedOptions.map((option, index) => { + const { key, ...optionProps } = getOptionProps({ option, index }); + return ( +
  • + {option.title} + +
  • + ); + })}
    ) : null} diff --git a/docs/data/material/components/autocomplete/CustomizedHook.tsx b/docs/data/material/components/autocomplete/CustomizedHook.tsx index 5fdd16e7cfae6a..66a216c698c4d7 100644 --- a/docs/data/material/components/autocomplete/CustomizedHook.tsx +++ b/docs/data/material/components/autocomplete/CustomizedHook.tsx @@ -179,20 +179,24 @@ export default function CustomizedHook() {
    - {value.map((option: FilmOptionType, index: number) => ( - - ))} + {value.map((option: FilmOptionType, index: number) => { + const { key, ...tagProps } = getTagProps({ index }); + return ; + })}
    {groupedOptions.length > 0 ? ( - {(groupedOptions as typeof top100Films).map((option, index) => ( -
  • - {option.title} - -
  • - ))} + {(groupedOptions as typeof top100Films).map((option, index) => { + const { key, ...optionProps } = getOptionProps({ option, index }); + return ( +
  • + {option.title} + +
  • + ); + })}
    ) : null} diff --git a/docs/data/material/components/autocomplete/Tags.js b/docs/data/material/components/autocomplete/Tags.js index 4e1de13f5d346e..05467cceca296b 100644 --- a/docs/data/material/components/autocomplete/Tags.js +++ b/docs/data/material/components/autocomplete/Tags.js @@ -44,9 +44,12 @@ export default function Tags() { defaultValue={[top100Films[13].title]} freeSolo renderTags={(value, getTagProps) => - value.map((option, index) => ( - - )) + value.map((option, index) => { + const { key, ...tagProps } = getTagProps({ index }); + return ( + + ); + }) } renderInput={(params) => ( - value.map((option: string, index: number) => ( - - )) + value.map((option: string, index: number) => { + const { key, ...tagProps } = getTagProps({ index }); + return ( + + ); + }) } renderInput={(params) => ( , - ) => React.HTMLAttributes; + ) => React.HTMLAttributes & { key: any }; /** * Id for the Autocomplete. */ diff --git a/packages/mui-material/src/Autocomplete/Autocomplete.js b/packages/mui-material/src/Autocomplete/Autocomplete.js index a81286fc3615ea..301c876212c78f 100644 --- a/packages/mui-material/src/Autocomplete/Autocomplete.js +++ b/packages/mui-material/src/Autocomplete/Autocomplete.js @@ -593,8 +593,9 @@ const Autocomplete = React.forwardRef(function Autocomplete(inProps, ref) { const renderGroup = renderGroupProp || defaultRenderGroup; const defaultRenderOption = (props2, option) => { // Need to clearly apply key because of https://github.com/vercel/next.js/issues/55642 + const { key, ...otherProps } = props2; return ( -
  • +
  • {getOptionLabel(option)}
  • );