react-virtuoso
react-virtuoso copied to clipboard
Expose active group index
I'm building something similar to https://virtuoso.dev/scroll-to-group/
I'd like to trigger some functionality whenever a new group index becomes active to do things like add an active class to the navigational buttons, but I can't seem to find anything that exposes the current active group index.
Am I missing something? Otherwise, I think it would be best to expose it in the scrollingStateChange or in itemsRendered
I did find a workaround by doing the following in itemsRendered callback, but would still be nice to have this exposed natively:
const itemsRenderCallback = items => {
const renderedGroupIndices = items.map(item => item.groupIndex)
setActiveGroupIndex(Math.min(...renderedGroupIndices))
}