petyosi / react-virtuoso

The most powerful virtual list component for React
https://virtuoso.dev
MIT License
5.13k stars 299 forks source link

React Virtuoso Message List - ref.current.scrollToItem based on the item.data instead of using the item index? #1077

Closed vasiline2256 closed 4 months ago

vasiline2256 commented 4 months ago

Hello, I have a list of Messages and a Message can be a reply to another Message, and when I clicked Goto Message button of a Reply Message I want to scroll to the original Message being replied to ( If it is already loaded with Load More after scrolling up )

I see that there is already a function:

ref.current.scrollToItem({index: 50, align: 'center' })

but this function seems to only accept the generated index value, is there a way to filter and get the index from the data passed to that Message instead?

because for me it is difficult to get the generated index for the Reply Message, since the Message Items are virtualized, I cannot use scrollIntoView() with id for this, or is there some other way that can accomplish this?