From f12bbe80f0daec1edceba7a1ac4938aa948eab8c Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sat, 14 Aug 2021 23:30:07 +0200 Subject: [PATCH] [core] Skip update on initial render --- .../grid/hooks/features/columns/useGridColumns.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/grid/_modules_/grid/hooks/features/columns/useGridColumns.ts b/packages/grid/_modules_/grid/hooks/features/columns/useGridColumns.ts index 04eead246e20..0a04a2c3b8b5 100644 --- a/packages/grid/_modules_/grid/hooks/features/columns/useGridColumns.ts +++ b/packages/grid/_modules_/grid/hooks/features/columns/useGridColumns.ts @@ -334,6 +334,13 @@ export function useGridColumns( logger.debug( `GridColumns gridState.viewportSizes.width, changed ${gridState.viewportSizes.width}`, ); + + // This hook is meant to update the column's width when the viewport changes + // We can skip the whole block if the width is missing + if (gridState.viewportSizes.width === 0) { + return; + } + // Avoid dependency on gridState as I only want to update cols when viewport size changed. const currentColumns = allGridColumnsSelector(apiRef.current.state);