From 41930c7f192dfdac11b7ba2918cd4d5787c18a44 Mon Sep 17 00:00:00 2001 From: David Matejka Date: Tue, 2 Jul 2024 16:46:00 +0200 Subject: [PATCH] fix(react-ui-lib): fix re-rendering of datagrid columns --- packages/react-ui-lib/src/datagrid/table.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-ui-lib/src/datagrid/table.tsx b/packages/react-ui-lib/src/datagrid/table.tsx index 182d1655a..0dad29e47 100644 --- a/packages/react-ui-lib/src/datagrid/table.tsx +++ b/packages/react-ui-lib/src/datagrid/table.tsx @@ -1,7 +1,7 @@ import { Component, Environment } from '@contember/interface' import { Table, TableBody, TableHeader, TableRow } from '../ui/table' import * as React from 'react' -import { Fragment, ReactNode, useState } from 'react' +import { Fragment, ReactNode, useMemo } from 'react' import { DataViewEachRow, DataViewLayout } from '@contember/react-dataview' import { SheetIcon } from 'lucide-react' import { dict } from '../dict' @@ -28,7 +28,7 @@ export const DataGridTable = Component(({ children }) => { }) const DataGridTableRenderer = Component< DataViewTableProps>(({ children }, env) => { - const [columns] = useState(() => datagridColumnsAnalyzer.processChildren(children, env)) + const columns = useMemo(() => datagridColumnsAnalyzer.processChildren(children, env), [children, env]) return (