Skip to content

Commit 850bd84

Browse files
Merge pull request #622 from shapehq/copilot/sub-pr-607
Use change.id as React key instead of array index
2 parents 0ad48be + a2e5999 commit 850bd84

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

src/features/sidebar/view/internal/diffbar/components/DiffList.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
import { Box, Typography } from "@mui/material"
44
import PopulatedDiffList from "./PopulatedDiffList"
5-
6-
interface Change {
7-
path?: string
8-
text?: string
9-
}
5+
import { DiffChange } from "@/features/diff/domain/DiffChange"
106

117
export type DiffListStatus = "idle" | "loading" | "empty" | "ready" | "error"
128

@@ -16,7 +12,7 @@ const DiffList = ({
1612
selectedChange,
1713
onClick,
1814
}: {
19-
changes: Change[]
15+
changes: DiffChange[]
2016
status: DiffListStatus
2117
selectedChange: number | null
2218
onClick: (i: number) => void

src/features/sidebar/view/internal/diffbar/components/PopulatedDiffList.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@
22

33
import SpacedList from "@/common/ui/SpacedList"
44
import DiffListItem from "./DiffListItem"
5-
6-
interface Change {
7-
path?: string;
8-
text?: string;
9-
}
5+
import { DiffChange } from "@/features/diff/domain/DiffChange"
106

117
const PopulatedDiffList = ({
128
changes,
139
selectedChange,
1410
onClick,
1511
}: {
16-
changes: Change[]
12+
changes: DiffChange[]
1713
selectedChange: number | null
1814
onClick: (i: number) => void
1915
}) => {
@@ -27,7 +23,7 @@ const PopulatedDiffList = ({
2723
>
2824
{changes.map((change, i) => (
2925
<DiffListItem
30-
key={i}
26+
key={change.id}
3127
path={change?.path}
3228
text={change?.text}
3329
selected={selectedChange === i}

0 commit comments

Comments
 (0)