CellMeasurer has wrong measurements for FIRST batch only
See original GitHub issueI’m using the CellMeasurer
in order to calculate a VirtualScroll
’ row’s height, and it’s using a completely wrong measurement for the initial batch of visible rows.
This ends up something like the following (the top 4 rows were a part of the initial batch, and have a very tall height):
The virtualized components that I’m using are as follows:
<WindowScroller>
{ ({ height, scrollTop }) =>
<AutoSizer disableHeight>
{ ({ width }) =>
<CellMeasurer
cellRenderer={ cell => this.renderVirtualRow(cell.rowIndex) }
columnCount={ 1 }
rowCount={ items.length }
width={ width } >
{ ({ getRowHeight }) =>
<VirtualScroll
autoHeight
style={ { background: '#EEE' } }
width={ width }
height={ height }
scrollTop={ scrollTop }
rowCount={ items.length }
rowHeight={ getRowHeight }
rowRenderer={ row => this.renderVirtualRow(row.index) } />
}
</CellMeasurer>
}
</AutoSizer>
}
</WindowScroller>
If I scroll, the rows that get rendered all have the correct heights, but the initial batched rows are still all wrong.
It’s happening on both Chrome and FireFox.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Row heights are wrong with react-virtualized List and ...
I am brand new to React.js (this is my first project in React, so some of the bad design is probably attributable to...
Read more >types/react-virtualized@9.21.21 - jsDocs.io
Typically cells are only measured as needed and estimated sizes are used for cells that have not yet been measured. This method ensures...
Read more >masonic - npm
An autosizing masonry grid component that only renders items currently viewable in the window. This component will change its column count to ...
Read more >react-virtualized List TypeScript Examples - ProgramCreek.com
This page shows TypeScript code examples of react-virtualized List. ... FC<ListProps> = ({ width, height, rowCount, rowHeight, rowRenderer, ...
Read more >Create a Virtualized List with Auto Sizing Cells using react ...
These allow for dynamic just-in-time measurements of your rows. [00:19] The first thing we need to do is set up a cache. Say...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @bvaughn
FWIW I encountered the same issue, in a Next.js SSR app. I think your diagnostic is correct, but I couldn’t figure out how to improve the measurement as everything in my design is fluid, and inside a swipe-view to make it even more complicated.
My solution was as follows:
Closing for now. Don’t have enough info to help diagnose this further.
Comments will still notify me via email- so if you get a chance to provide a Plunker or some way to reproduce, let me know and I’ll be happy to take another look. 😃