Skip to content

Commit

Permalink
fix: Provide keys are array components
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverroick committed Feb 8, 2024
1 parent 6b9b9c5 commit 7980e4e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/pages/ItemDetail/PropertyList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ function PropertyList({ properties, headerLevel = "h2" }: PropertyListProps) {
.filter(([ key ]: PropType) => !IGNORE_PROPS.includes(key))
.map(([ key, val ]: PropType, index: number) => (
(val.itemOrder && val.itemOrder.length > 1) ? (
<>
<Box key={key}>
<Text>{val.label}</Text>
<TableContainer key={key}>
<TableContainer>
<Table size="sm">
<Thead>
<Tr>
Expand All @@ -34,7 +34,7 @@ function PropertyList({ properties, headerLevel = "h2" }: PropertyListProps) {
</Thead>
<Tbody>
{ val.value.map((value) => (
<Tr key={value.name}>
<Tr key={JSON.stringify(value)}>
{val.itemOrder.map((item) => (
<Td key={item} valign="top">
<TableValue value={value[item]} />
Expand All @@ -45,7 +45,7 @@ function PropertyList({ properties, headerLevel = "h2" }: PropertyListProps) {
</Tbody>
</Table>
</TableContainer>
</>
</Box>
) : (
<Box
key={key}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/ItemDetail/TableValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ function TableValue({ value }: TableValueProps) {
if (Array.isArray(value)) {
return (
<UnorderedList my="0">
{value.map(v => <ListItem key={v}>{v}</ListItem>)}
{/* eslint-disable-next-line react/no-array-index-key */}
{value.map((v, i) => <ListItem key={`${i}-${v}`}>{v}</ListItem>)}
</UnorderedList>
);
}
Expand Down

0 comments on commit 7980e4e

Please sign in to comment.