From 3855486a00fdf61966a0f7a232a7e49945681777 Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Mon, 11 May 2026 19:27:00 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20prevent=20`SitetableCell`?= =?UTF-8?q?=20from=20rerendering=20unnecessarily?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/SitesTable.tsx | 43 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/components/SitesTable.tsx b/src/components/SitesTable.tsx index b8064c933..dfef6d6a1 100644 --- a/src/components/SitesTable.tsx +++ b/src/components/SitesTable.tsx @@ -45,6 +45,7 @@ import { usePathname, useRouter } from "next/navigation"; import { startTransition, useEffect, + useMemo, useOptimistic, useState, useTransition @@ -180,7 +181,8 @@ export default function SitesTable({ }); } - const columns: ExtendedColumnDef[] = [ + const columns = useMemo[]>(() => { + const cols: ExtendedColumnDef[] = [ { accessorKey: "name", enableHiding: false, @@ -470,26 +472,6 @@ export default function SitesTable({ ); } }, - ...(isLabelFeatureEnabled - ? [ - { - accessorKey: "labels", - header: () => ( - - {t("labels")} - - ), - cell: ({ row }: { row: { original: SiteRow } }) => { - return ( - - ); - } - } - ] - : []), { id: "actions", enableHiding: false, @@ -544,7 +526,24 @@ export default function SitesTable({ ); } } - ]; + ]; + + if (isLabelFeatureEnabled) { + cols.splice(cols.length - 1, 0, { + accessorKey: "labels", + header: () => ( + + {t("labels")} + + ), + cell: ({ row }: { row: { original: SiteRow } }) => ( + + ) + }); + } + + return cols; + }, [isLabelFeatureEnabled, orgId, t, searchParams]); function toggleSort(column: string) { const newSearch = getNextSortOrder(column, searchParams);