bvaughn/react-virtualized · warning
Fixed height CellMeasurerCache should specify a :defaultHeig
Error message
Fixed height CellMeasurerCache should specify a :defaultHeight greater than 0. Failing to do so will lead to unnecessary layout and poor performance.
What it means
When height is NOT fixed (`fixedHeight` is false), CellMeasurerCache uses `defaultHeight` as the estimated height for unmeasured cells. A default of 0 makes the grid render zero-height rows initially, forcing constant relayout/remeasure as cells become visible. Dev-mode console warning only.
Source
Thrown at source/CellMeasurer/CellMeasurerCache.js:84
this._minHeight,
typeof defaultHeight === 'number' ? defaultHeight : DEFAULT_HEIGHT,
);
this._defaultWidth = Math.max(
this._minWidth,
typeof defaultWidth === 'number' ? defaultWidth : DEFAULT_WIDTH,
);
if (process.env.NODE_ENV !== 'production') {
if (this._hasFixedHeight === false && this._hasFixedWidth === false) {
console.warn(
"CellMeasurerCache should only measure a cell's width or height. " +
'You have configured CellMeasurerCache to measure both. ' +
'This will result in poor performance.',
);
}
if (this._hasFixedHeight === false && this._defaultHeight === 0) {
console.warn(
'Fixed height CellMeasurerCache should specify a :defaultHeight greater than 0. ' +
'Failing to do so will lead to unnecessary layout and poor performance.',
);
}
if (this._hasFixedWidth === false && this._defaultWidth === 0) {
console.warn(
'Fixed width CellMeasurerCache should specify a :defaultWidth greater than 0. ' +
'Failing to do so will lead to unnecessary layout and poor performance.',
);
}
}
}
clear(rowIndex: number, columnIndex: number = 0) {
const key = this._keyMapper(rowIndex, columnIndex);
delete this._cellHeightCache[key];View on GitHub (pinned to c737715486)
Solutions
- Pass an explicit `defaultHeight` greater than 0 (a realistic average row height).
- Set `fixedHeight: true` if heights are actually constant, providing `defaultHeight` as that constant.
- Tune `defaultHeight` close to real content height to minimize reflow/jumping.
Example fix
// before
const cache = new CellMeasurerCache({ fixedWidth: true });
// after
const cache = new CellMeasurerCache({ fixedWidth: true, defaultHeight: 64 }); Defensive patterns
Strategy: validation
Validate before calling
if (!opts.fixedHeight && !(opts.defaultHeight > 0)) throw new Error('Provide defaultHeight > 0 for CellMeasurerCache'); Prevention
- Pair fixedWidth:true with an explicit defaultHeight
- Estimate defaultHeight from real content metrics
- Wrap cache creation in a helper enforcing invariants
When it happens
Trigger: `new CellMeasurerCache({fixedWidth: true})` (or neither fixed) without supplying `defaultHeight`, since the default is 0.
Common situations: Setting `fixedWidth: true` but forgetting `defaultHeight`; assuming the cache inherits a default height; scrollbars jumping because rows start at 0 height.
Related errors
- Fixed width CellMeasurerCache should specify a :defaultWidth
- CellMeasurerCache should only measure a cell's width or heig
- CellMeasurer registerChild expects to be passed Element or n
- Rendered cell should include style property for positioning.
- Invalid metadata returned for cell ${index}: x:${cel
AI-assisted analysis of bvaughn/react-virtualized@c737715486 (2026-08-30).
Data as JSON: /api/errors/a3175436112c0988.
Report an issue: GitHub.