Add key values to items in loop

This commit is contained in:
Jackson Harper 2023-10-25 12:56:34 +08:00
parent f49ffab649
commit 0a2bb2d172
2 changed files with 29 additions and 13 deletions

View file

@ -412,9 +412,16 @@ export default function LabelsPage(): JSX.Element {
if (editingLabelId == label.id) {
if (windowWidth >= breakpoint) {
return <DesktopEditCard {...cardProps} />
return (
<DesktopEditCard
key={`edit-${label.id}`}
{...cardProps}
/>
)
} else {
return <MobileEditCard {...cardProps} />
return (
<MobileEditCard key={`edit-${label.id}`} {...cardProps} />
)
}
}

View file

@ -488,9 +488,19 @@ export default function SavedSearchesPage(): JSX.Element {
}
if (editingId == savedSearch.id) {
if (windowWidth >= breakpoint) {
return <DesktopEditCard {...cardProps} />
return (
<DesktopEditCard
key={`edit-${savedSearch.id}`}
{...cardProps}
/>
)
} else {
return <MobileEditCard {...cardProps} />
return (
<MobileEditCard
key={`edit-${savedSearch.id}`}
{...cardProps}
/>
)
}
}
@ -569,15 +579,14 @@ function GenericTableCard(
editingId === savedSearch?.id || (isCreateMode && !savedSearch)
const iconColor = isDarkTheme() ? '#D8D7D5' : '#5F5E58'
const DEFAULT_STYLE = { position: null }
const [style, setStyle] =
useState<
Partial<{
position: string | null
top: string
left: string
maxWidth: string
}>
>(DEFAULT_STYLE)
const [style, setStyle] = useState<
Partial<{
position: string | null
top: string
left: string
maxWidth: string
}>
>(DEFAULT_STYLE)
const handleEdit = () => {
editingId && updateSavedSearch(editingId)
setEditingId(null)