react-virtuoso icon indicating copy to clipboard operation
react-virtuoso copied to clipboard

Expose active group index

Open NerdCowboy opened this issue 6 years ago • 1 comments

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

NerdCowboy avatar Oct 15 '19 19:10 NerdCowboy

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))
  }

NerdCowboy avatar Oct 15 '19 21:10 NerdCowboy