{"record":{"id":"9da7701741640dab","repo":"bvaughn/react-virtualized","slug":"cellmeasurercache-should-only-measure-a-cell-s-wid","errorCode":null,"errorMessage":"CellMeasurerCache should only measure a cell's width or height. You have configured CellMeasurerCache to measure both. This will result in poor performance.","messagePattern":"CellMeasurerCache should only measure a cell's width or height\\. You have configured CellMeasurerCache to measure both\\. This will result in poor performance\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"source/CellMeasurer/CellMeasurerCache.js","lineNumber":76,"sourceCode":"\n    this._hasFixedHeight = fixedHeight === true;\n    this._hasFixedWidth = fixedWidth === true;\n    this._minHeight = minHeight || 0;\n    this._minWidth = minWidth || 0;\n    this._keyMapper = keyMapper || defaultKeyMapper;\n\n    this._defaultHeight = Math.max(\n      this._minHeight,\n      typeof defaultHeight === 'number' ? defaultHeight : DEFAULT_HEIGHT,\n    );\n    this._defaultWidth = Math.max(\n      this._minWidth,\n      typeof defaultWidth === 'number' ? defaultWidth : DEFAULT_WIDTH,\n    );\n\n    if (process.env.NODE_ENV !== 'production') {\n      if (this._hasFixedHeight === false && this._hasFixedWidth === false) {\n        console.warn(\n          \"CellMeasurerCache should only measure a cell's width or height. \" +\n            'You have configured CellMeasurerCache to measure both. ' +\n            'This will result in poor performance.',\n        );\n      }\n\n      if (this._hasFixedHeight === false && this._defaultHeight === 0) {\n        console.warn(\n          'Fixed height CellMeasurerCache should specify a :defaultHeight greater than 0. ' +\n            'Failing to do so will lead to unnecessary layout and poor performance.',\n        );\n      }\n\n      if (this._hasFixedWidth === false && this._defaultWidth === 0) {\n        console.warn(\n          'Fixed width CellMeasurerCache should specify a :defaultWidth greater than 0. ' +\n            'Failing to do so will lead to unnecessary layout and poor performance.',\n        );","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/bvaughn/react-virtualized/blob/c737715486f724586aee8870ebea1e9efb7b0bfe/source/CellMeasurer/CellMeasurerCache.js#L58-L94","documentation":"CellMeasurerCache warns when neither `fixedWidth` nor `fixedHeight` is set, meaning it will measure both dimensions of every cell. Measuring both axes requires expensive DOM reads and two-pass layout, which the library flags as a performance problem. It is a dev-mode warning, not a thrown exception.","triggerScenarios":"Constructing `new CellMeasurerCache()` with no options, or with `{fixedWidth: false, fixedHeight: false}`, while using CellMeasurer/Grid.","commonSituations":"Copy-pasting a CellMeasurer example without the cache options; dynamic-content cells where developers assume both dimensions must be measured; migrating from another virtualization lib.","solutions":["Set `fixedHeight: true` when row height varies but width is known (most common: lists/grids with fixed column width).","Set `fixedWidth: true` when width varies but height is fixed.","If both truly vary, accept the warning or restructure content so one dimension is fixed (e.g. fixed width container).","Pass the same cache instance consistently to CellMeasurer and the list/grid."],"exampleFix":"// before\nconst cache = new CellMeasurerCache();\n\n// after\nconst cache = new CellMeasurerCache({ fixedWidth: true, defaultHeight: 50 });","handlingStrategy":"validation","validationCode":"const cache = new CellMeasurerCache(opts);\nif (process.env.NODE_ENV !== 'production' && !opts?.fixedWidth && !opts?.fixedHeight) {\n  console.warn('Fix: set fixedWidth or fixedHeight on CellMeasurerCache');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass fixedWidth or fixedHeight when creating the cache","Centralize cache creation in one factory function with sane defaults","Treat dev warnings as build errors in CI where possible"],"tags":["performance","cellmeasurer","configuration"],"backgroundTag":"cellmeasurer-measures-both-dimensions","analyzedSha":"c737715486f724586aee8870ebea1e9efb7b0bfe","analyzedAt":"2026-08-30T00:33:38.249Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}