T
TanStack3y ago
foreign-sapphire

Modify size of element on click

Each row can be clicked, which expands the row to show more data. I'm storing the state of what's open within a state object Record<string, boolean. My estimate size fn looks like:
estimateSize: (index) => {
return (open[filteredLogs[index].id] ? 150 : 28);
},
estimateSize: (index) => {
return (open[filteredLogs[index].id] ? 150 : 28);
},
This works when new data comes in, however useVirtualizer doesn't seem to re-render when my own state changes. Is there a way to handle this?
2 Replies
foreign-sapphire
foreign-sapphireOP3y ago
Ah got it, virtual.resizeItem(item, isOpen ? 150 : 28);
sunny-green
sunny-green3y ago
Ooo true, because now estimateSize is not a dependency when building measurements array it's not easy to update the sizes. We can change it but then estimateSize need to be stale, nevertheless we should change the signature of resizeItem, to resive key not a virutal item cc @Tanner Linsley what do you think?

Did you find this page helpful?