From 3f52ff6fceddbce0d538dce410e734b2131b4eb3 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 3 May 2023 12:22:39 +0200 Subject: [PATCH] [ML] Transforms/DFA: Render EuiDataGrad for more than 0 rows. (#156403) Fixes the React dev mode warning "Warning: Can't perform a React state update on an unmounted component." by only rendering `EuiDataGrid` if there's more than 0 rows. --- .../components/data_grid/data_grid.tsx | 136 +++++++++--------- 1 file changed, 69 insertions(+), 67 deletions(-) diff --git a/x-pack/plugins/ml/public/application/components/data_grid/data_grid.tsx b/x-pack/plugins/ml/public/application/components/data_grid/data_grid.tsx index 8a290ee186a98..9d5422be1256d 100644 --- a/x-pack/plugins/ml/public/application/components/data_grid/data_grid.tsx +++ b/x-pack/plugins/ml/public/application/components/data_grid/data_grid.tsx @@ -346,74 +346,76 @@ export const DataGrid: FC = memo( )} - - {(mutationRef) => ( -
- { - c.initialWidth = 165; - return c; - })} - columnVisibility={{ visibleColumns, setVisibleColumns }} - trailingControlColumns={trailingControlColumns} - gridStyle={euiDataGridStyle} - rowCount={rowCount} - renderCellValue={renderCellValue} - renderCellPopover={renderCellPopover} - sorting={{ columns: sortingColumns, onSort }} - toolbarVisibility={{ - ...euiDataGridToolbarSettings, - ...(chartsButtonVisible - ? { - additionalControls: ( - - 0 && ( + + {(mutationRef) => ( +
+ { + c.initialWidth = 165; + return c; + })} + columnVisibility={{ visibleColumns, setVisibleColumns }} + trailingControlColumns={trailingControlColumns} + gridStyle={euiDataGridStyle} + rowCount={rowCount} + renderCellValue={renderCellValue} + renderCellPopover={renderCellPopover} + sorting={{ columns: sortingColumns, onSort }} + toolbarVisibility={{ + ...euiDataGridToolbarSettings, + ...(chartsButtonVisible + ? { + additionalControls: ( + - - - - ), - } - : {}), - }} - pagination={{ - ...pagination, - pageSizeOptions: [5, 10, 25], - onChangeItemsPerPage, - onChangePage, - }} - /> -
- )} -
+ + + +
+ ), + } + : {}), + }} + pagination={{ + ...pagination, + pageSizeOptions: [5, 10, 25], + onChangeItemsPerPage, + onChangePage, + }} + /> +
+ )} +
+ )} ); },