T
TanStack3mo ago
dependent-tan

Nested virtualizers?

I have a CommentsList component that I'm showing in a drawer, which is a scrollable list with comments. Each comments can have replies which can be toggled via a "show/hide replies" button on each comment. These replies can then also have replies, nested indefinitely. I know how to virtualize the main comments list, but if a comment has a massive amount of replies, how would I virtualize that too but have the comments be in the same scrollable list? If you've used Reddit, their comments system (w/ nested replies) would be a good representation of how I'd like things to work. Thanks!
2 Replies
dependent-tan
dependent-tan3mo ago
You’ve got a couple of options here: * Keep the list flat when rendering, meaning you transform your nested comments into a flat list when rendering * Share a single scroll element across all levels, just remember to set scrollMargin, initialOffset
conscious-sapphire
conscious-sapphire2mo ago
is there an example of how to use scrollMargin? I am essentially trying the same thing but with sticky headers

Did you find this page helpful?