List doesn't update display or row heights when data updated.
See original GitHub issueSetup
I have this List
that uses CellMeasurer
to compute row heights dynamically.
<WindowScroller ref={ref => (this.windowScroller = ref)}>
{({ height, isScrolling, onChildScroll, scrollTop }) => (
<AutoSizer disableHeight={true}>
{({ width }) => (
<div>
<List
autoHeight={true}
height={height}
isScrolling={isScrolling}
onScroll={onChildScroll}
scrollTop={scrollTop}
rowCount={contacts.length}
rowHeight={this._cache.rowHeight}
rowRenderer={this._rowRenderer}
width={width}
deferredMeasurementCache={this._cache}
overscanRowCount={0}
/>
</div>
)}
</AutoSizer>
)}
</WindowScroller>
Problem The list doesn’t update either display or row heights when data has changed. For the list to change, I have to scroll the window manually. I’ve tried to clear the cache, updatePosition and forceRender but still has no effect.
Temporary Solution
Since scrolling to update isn’t acceptable, I created a hack in the componentDidUpdate
to be able to update the list when data changes.
/**
* Since virtual list doesn't update till it scrolls, programmatically scroll window to
* trigger update.
*/
public componentDidUpdate(prevProps: Props) {
const becameVisible = this.props.isVisible && !prevProps.isVisible;
const contactChanged = this.props.contacts !== prevProps.contacts;
if (this.windowScroller && (becameVisible || contactChanged)) {
this._cache.clearAll();
this.windowScroller!.updatePosition();
window.scrollTo(window.scrollX, window.scrollY + 5);
window.scrollTo(window.scrollX, window.scrollY - 5);
}
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:14
- Comments:11
Top Results From Across the Web
Dynamic row heights with react-virtualized and new ...
I need to update the row heights when the list data has changed. The current CellMeasurer doc doesn't seem to have any info...
Read more >Add row to data list does not expand panel | Justinmind Q&A
I have a data list in a dynamic panel. My hope was that as new rows are added to the data list, the...
Read more >Change the column width and row height - Microsoft Support
Go to File > Options > Advanced > Display > select an option from the Ruler Units list. If you switch to Normal...
Read more >How to change and AutoFit row height in Excel - Ablebits
When copying data into Excel sheets, there are times when a row height does not adjust automatically. As the result, multi-line or unusually ......
Read more >Working with Data: Updating Data - AG Grid
Insert Row @ 2: Inserts a row at position 2 in the list. This works in the grid as it doesn't allow sorting,...
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
for me this didn’t work, so I dynamically set an “artificial” key on the
List
, and I bump it by 1 to programmatically force a rerenderYou can add ref
the
bindListRef
functionAt last, call
forceUpdateGrid
inComponentDidUpdate