fix: resizing reset when data changes

This commit is contained in:
dongchengjie 2024-06-17 13:03:47 +08:00
parent 18f0177fce
commit af89630095

View File

@ -17,7 +17,7 @@ export const ConnectionTable = (props: Props) => {
Partial<Record<keyof IConnectionsItem, boolean>> Partial<Record<keyof IConnectionsItem, boolean>>
>({}); >({});
const columns: GridColDef[] = [ const [columns] = useState<GridColDef[]>([
{ field: "host", headerName: t("Host"), flex: 220, minWidth: 220 }, { field: "host", headerName: t("Host"), flex: 220, minWidth: 220 },
{ {
field: "download", field: "download",
@ -61,9 +61,8 @@ export const ConnectionTable = (props: Props) => {
minWidth: 100, minWidth: 100,
align: "right", align: "right",
headerAlign: "right", headerAlign: "right",
sortComparator: (v1: string, v2: string) => { sortComparator: (v1: string, v2: string) =>
return new Date(v2).getTime() - new Date(v1).getTime(); new Date(v2).getTime() - new Date(v1).getTime(),
},
valueFormatter: (value: number) => dayjs(value).fromNow(), valueFormatter: (value: number) => dayjs(value).fromNow(),
}, },
{ field: "source", headerName: t("Source"), flex: 200, minWidth: 130 }, { field: "source", headerName: t("Source"), flex: 200, minWidth: 130 },
@ -74,7 +73,7 @@ export const ConnectionTable = (props: Props) => {
minWidth: 130, minWidth: 130,
}, },
{ field: "type", headerName: t("Type"), flex: 160, minWidth: 100 }, { field: "type", headerName: t("Type"), flex: 160, minWidth: 100 },
]; ]);
const connRows = useMemo(() => { const connRows = useMemo(() => {
return connections.map((each) => { return connections.map((each) => {