Skip to content

Commit 2724866

Browse files
Use change.id as React key instead of array index
Co-authored-by: ulrikandersen <11440456+ulrikandersen@users.noreply.github.com>
1 parent af121ce commit 2724866

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
@@ -3,18 +3,14 @@
33
import React from "react";
44
import SpacedList from "@/common/ui/SpacedList";
55
import DiffListItem from "./DiffListItem";
6-
7-
interface Change {
8-
path?: string;
9-
text?: string;
10-
}
6+
import { DiffChange } from "@/features/diff/domain/DiffChange";
117

128
const PopulatedDiffList = ({
139
changes,
1410
selectedChange,
1511
onClick,
1612
}: {
17-
changes: Change[];
13+
changes: DiffChange[];
1814
selectedChange: number | null;
1915
onClick: (i: number) => void;
2016
}) => {
@@ -28,7 +24,7 @@ const PopulatedDiffList = ({
2824
>
2925
{changes.map((change, i) => (
3026
<DiffListItem
31-
key={i}
27+
key={change.id}
3228
path={change?.path}
3329
text={change?.text}
3430
selected={selectedChange === i}

0 commit comments

Comments
 (0)