From e146aa844e9edcf3a968ba19e1c48d3fd5c05331 Mon Sep 17 00:00:00 2001 From: RyanHu021 Date: Thu, 30 May 2024 10:40:41 -0700 Subject: [PATCH] fix: one more table sizing bug --- src/components/admin/admin-table/admin-table.tsx | 7 +++++-- .../sponsored-org/sponsored-org-table/data-table.tsx | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/admin/admin-table/admin-table.tsx b/src/components/admin/admin-table/admin-table.tsx index ea4e7d2..528d784 100644 --- a/src/components/admin/admin-table/admin-table.tsx +++ b/src/components/admin/admin-table/admin-table.tsx @@ -104,15 +104,18 @@ export default function AdminTable() { .then((reimbursements) => { setReimbursements(reimbursements); setIsLoading(false); - handleWindowResize(); }) .catch((err) => { setError(err); setIsLoading(false); }); + }, []); + + React.useEffect(() => { + handleWindowResize(); window.addEventListener("resize", handleWindowResize); return () => window.removeEventListener("resize", handleWindowResize); - }, []); + }, [reimbursements]); const table = useReactTable({ data: reimbursements, diff --git a/src/components/sponsored-org/sponsored-org-table/data-table.tsx b/src/components/sponsored-org/sponsored-org-table/data-table.tsx index f019c2d..df40dbd 100644 --- a/src/components/sponsored-org/sponsored-org-table/data-table.tsx +++ b/src/components/sponsored-org/sponsored-org-table/data-table.tsx @@ -64,7 +64,7 @@ export function DataTable({ columns, data }: DataTableProps window.removeEventListener("resize", handleWindowResize); - }, []); + }, [data]); const table = useReactTable({ data,