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);