From 5e907ea0b55d8bd70d0c8c32b8948a690b8959e2 Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Tue, 3 Dec 2019 09:42:12 +0100 Subject: [PATCH] refactor --- scm-ui/ui-components/src/table/Table.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scm-ui/ui-components/src/table/Table.tsx b/scm-ui/ui-components/src/table/Table.tsx index c89c72e89e..6d9ccca5c5 100644 --- a/scm-ui/ui-components/src/table/Table.tsx +++ b/scm-ui/ui-components/src/table/Table.tsx @@ -65,6 +65,10 @@ const Table: FC = ({ data, sortable, children }) => { setlastSortBy(index); }; + const shouldShowIcon = (index: number) => { + return index === lastSortBy || index === hoveredColumnIndex; + }; + return ( tableData.length > 0 && ( @@ -81,8 +85,7 @@ const Table: FC = ({ data, sortable, children }) => { // @ts-ignore child.props.header } - {isSortable(child) && - renderSortIcon(child, ascending, index === lastSortBy || index === hoveredColumnIndex)} + {isSortable(child) && renderSortIcon(child, ascending, shouldShowIcon(index))} ))}