From 72d4cc40636f191616653fdab32e087c0f6aacc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aar=C3=B3n=20Garc=C3=ADa=20Herv=C3=A1s?= Date: Thu, 20 Jun 2024 01:15:50 +0200 Subject: [PATCH] Fix React 18.3 key spread warnings in Autocomplete demos --- .../components/autocomplete/FixedTags.js | 18 +++++---- .../components/autocomplete/FixedTags.tsx | 18 +++++---- .../material/components/autocomplete/Sizes.js | 40 +++++++++++-------- .../components/autocomplete/Sizes.tsx | 40 +++++++++++-------- 4 files changed, 70 insertions(+), 46 deletions(-) diff --git a/docs/data/material/components/autocomplete/FixedTags.js b/docs/data/material/components/autocomplete/FixedTags.js index fc57e587e221b3..982b9f1f35c706 100644 --- a/docs/data/material/components/autocomplete/FixedTags.js +++ b/docs/data/material/components/autocomplete/FixedTags.js @@ -21,13 +21,17 @@ export default function FixedTags() { options={top100Films} getOptionLabel={(option) => option.title} renderTags={(tagValue, getTagProps) => - tagValue.map((option, index) => ( - - )) + tagValue.map((option, index) => { + const { key, ...tagProps } = getTagProps({ index }); + return ( + + ); + }) } style={{ width: 500 }} renderInput={(params) => ( diff --git a/docs/data/material/components/autocomplete/FixedTags.tsx b/docs/data/material/components/autocomplete/FixedTags.tsx index fc57e587e221b3..982b9f1f35c706 100644 --- a/docs/data/material/components/autocomplete/FixedTags.tsx +++ b/docs/data/material/components/autocomplete/FixedTags.tsx @@ -21,13 +21,17 @@ export default function FixedTags() { options={top100Films} getOptionLabel={(option) => option.title} renderTags={(tagValue, getTagProps) => - tagValue.map((option, index) => ( - - )) + tagValue.map((option, index) => { + const { key, ...tagProps } = getTagProps({ index }); + return ( + + ); + }) } style={{ width: 500 }} renderInput={(params) => ( diff --git a/docs/data/material/components/autocomplete/Sizes.js b/docs/data/material/components/autocomplete/Sizes.js index ca0235e0bc38d6..741046dabddb9d 100644 --- a/docs/data/material/components/autocomplete/Sizes.js +++ b/docs/data/material/components/autocomplete/Sizes.js @@ -66,14 +66,18 @@ export default function Sizes() { getOptionLabel={(option) => option.title} defaultValue={top100Films[13]} renderTags={(value, getTagProps) => - value.map((option, index) => ( - - )) + value.map((option, index) => { + const { key, ...tagProps } = getTagProps({ index }); + return ( + + ); + }) } renderInput={(params) => ( option.title} defaultValue={[top100Films[13]]} renderTags={(value, getTagProps) => - value.map((option, index) => ( - - )) + value.map((option, index) => { + const { key, ...tagProps } = getTagProps({ index }); + return ( + + ); + }) } renderInput={(params) => ( option.title} defaultValue={top100Films[13]} renderTags={(value, getTagProps) => - value.map((option, index) => ( - - )) + value.map((option, index) => { + const { key, ...tagProps } = getTagProps({ index }); + return ( + + ); + }) } renderInput={(params) => ( option.title} defaultValue={[top100Films[13]]} renderTags={(value, getTagProps) => - value.map((option, index) => ( - - )) + value.map((option, index) => { + const { key, ...tagProps } = getTagProps({ index }); + return ( + + ); + }) } renderInput={(params) => (