bvaughn / react-window

React components for efficiently rendering large lists and tabular data
https://react-window.now.sh/
MIT License
15.54k stars 779 forks source link

Dynamic row height issue with react table #704

Open robertmiddlekauffmckinsey opened 1 year ago

robertmiddlekauffmckinsey commented 1 year ago

I implemented a solution to modifying row height by attaching refs on each items and then use clientHeight (https://tiagohorta1995.medium.com/dynamic-list-virtualization-using-react-window-ab6fbf10bfb2), but when I sort or filter the table I am having trouble getting the rowHeight object to update.

Here is it with the sort broken. To recreate just sort the status column and you'll see that the row heights are constant. This is likely because useEffect is not firing which makes sense. https://codesandbox.io/s/row-height-constant-after-sorting-kt1b51?file=/src/App.js

The react docs recommend using useCallback instead (https://reactjs.org/docs/hooks-faq.html#how-can-i-measure-a-dom-node), but when I do that, ListRef gets an error that it doesn't exist: https://codesandbox.io/s/row-height-constant-after-sorting-with-callback-wn8tre?file=/src/App.js

Does anyone know what I might be missing or how I might fix this?