bvaughn / react-virtualized

React components for efficiently rendering large lists and tabular data
http://bvaughn.github.io/react-virtualized/
MIT License
26.1k stars 3.05k forks source link

How to notify List component that its row item height has changed? #1774

Open yelnyafacee opened 1 year ago

yelnyafacee commented 1 year ago

I have a react-virtualized List, each item in the rows have an expand button, when the button is clicked the height of the row changes and it expands and show more info.

the issue here is, after the button got clicked the inner Grid (ReactVirtualizedGridinnerScrollContainer) CSS height property is not updating or the Gid is not re-rendering/notified of the changes in row height

What should I do to make it rerender the row everytime the row item height gets updated?

I tried using forceUpdateGrid() with useRef() but it does not seems to work? or maybe I did it wrong?

Sandbox code: https://codesandbox.io/s/agitated-pond-xq1csq?file=/pages/index.js

codedaybyday commented 1 year ago

you need use CellMeasurer and CellMeasurerCache, when someone item has update height, you should clear one of CellMeasurerCache, then rerender

aleksandr-sidorov commented 7 months ago

@yelnyafacee You should warp your list item with the CellMeasurer. It passes the measure render prop to your component so you can call it in a function that changes its layout.