Skip to content

Commit 3e7577c

Browse files
Use useMemo for callback passed to AlertTableDropdownIndicatorCell.onClick in AlertTablePathRow
1 parent acb76a6 commit 3e7577c

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

extensions/ql-vscode/src/view/results/AlertTablePathRow.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { selectableZebraStripe } from "./result-table-utils";
55
import { ScrollIntoViewHelper } from "./scroll-into-view-helper";
66
import { AlertTablePathNodeRow } from "./AlertTablePathNodeRow";
77
import { AlertTableDropdownIndicatorCell } from "./AlertTableDropdownIndicatorCell";
8+
import { useMemo } from "react";
89

910
interface Props {
1011
path: Sarif.ThreadFlow;
@@ -35,7 +36,14 @@ export function AlertTablePathRow(props: Props) {
3536
scroller,
3637
} = props;
3738

38-
const pathKey = { resultIndex, pathIndex };
39+
const pathKey = useMemo(
40+
() => ({ resultIndex, pathIndex }),
41+
[pathIndex, resultIndex],
42+
);
43+
const handleDropdownClick = useMemo(
44+
() => toggler([pathKey]),
45+
[pathKey, toggler],
46+
);
3947

4048
const isPathSpecificallySelected = Keys.equalsNotUndefined(
4149
pathKey,
@@ -51,7 +59,7 @@ export function AlertTablePathRow(props: Props) {
5159
</td>
5260
<AlertTableDropdownIndicatorCell
5361
expanded={currentPathExpanded}
54-
onClick={toggler([pathKey])}
62+
onClick={handleDropdownClick}
5563
/>
5664
<td className="vscode-codeql__text-center" colSpan={3}>
5765
Path

0 commit comments

Comments
 (0)