Simplify comparisons with undefined

This commit is contained in:
Robert
2023-07-03 10:51:52 +01:00
parent 08a8d6396c
commit f0af593b67

View File

@@ -13,7 +13,7 @@ export function AlertTableHeader({
sortState?: InterpretedResultsSortState; sortState?: InterpretedResultsSortState;
}) { }) {
const sortClass = useCallback((): string => { const sortClass = useCallback((): string => {
if (sortState !== undefined && sortState.sortBy === "alert-message") { if (sortState?.sortBy === "alert-message") {
return sortState.sortDirection === SortDirection.asc return sortState.sortDirection === SortDirection.asc
? "sort-asc" ? "sort-asc"
: "sort-desc"; : "sort-desc";
@@ -26,7 +26,7 @@ export function AlertTableHeader({
| InterpretedResultsSortState | InterpretedResultsSortState
| undefined => { | undefined => {
const prevDirection = const prevDirection =
sortState && sortState.sortBy === "alert-message" sortState?.sortBy === "alert-message"
? sortState.sortDirection ? sortState.sortDirection
: undefined; : undefined;
const nextDirection = nextSortDirection(prevDirection, true); const nextDirection = nextSortDirection(prevDirection, true);