Use useMemo for callback passed to SarifLocation.onClick in AlertTableResultRow

This commit is contained in:
Robert
2023-08-16 15:04:33 +01:00
parent 636d0bf025
commit 3983087bc8

View File

@@ -42,6 +42,10 @@ export function AlertTableResultRow(props: Props) {
[resultIndex],
);
const handleSarifLocationClicked = useMemo(
() => updateSelectionCallback(resultKey),
[resultKey, updateSelectionCallback],
);
const handleDropdownClick = useMemo(() => {
const indices =
Keys.getAllPaths(result).length === 1
@@ -83,7 +87,7 @@ export function AlertTableResultRow(props: Props) {
loc={result.locations[0]}
sourceLocationPrefix={sourceLocationPrefix}
databaseUri={databaseUri}
onClick={updateSelectionCallback(resultKey)}
onClick={handleSarifLocationClicked}
/>
)}
</td>