From af896300951daae957dac9312e6982c4db0a751d Mon Sep 17 00:00:00 2001 From: dongchengjie <37543964+dongchengjie@users.noreply.github.com> Date: Mon, 17 Jun 2024 13:03:47 +0800 Subject: [PATCH] fix: resizing reset when data changes --- src/components/connection/connection-table.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/connection/connection-table.tsx b/src/components/connection/connection-table.tsx index 79ced8f6..f2daed6a 100644 --- a/src/components/connection/connection-table.tsx +++ b/src/components/connection/connection-table.tsx @@ -17,7 +17,7 @@ export const ConnectionTable = (props: Props) => { Partial> >({}); - const columns: GridColDef[] = [ + const [columns] = useState([ { field: "host", headerName: t("Host"), flex: 220, minWidth: 220 }, { field: "download", @@ -61,9 +61,8 @@ export const ConnectionTable = (props: Props) => { minWidth: 100, align: "right", headerAlign: "right", - sortComparator: (v1: string, v2: string) => { - return new Date(v2).getTime() - new Date(v1).getTime(); - }, + sortComparator: (v1: string, v2: string) => + new Date(v2).getTime() - new Date(v1).getTime(), valueFormatter: (value: number) => dayjs(value).fromNow(), }, { field: "source", headerName: t("Source"), flex: 200, minWidth: 130 }, @@ -74,7 +73,7 @@ export const ConnectionTable = (props: Props) => { minWidth: 130, }, { field: "type", headerName: t("Type"), flex: 160, minWidth: 100 }, - ]; + ]); const connRows = useMemo(() => { return connections.map((each) => {