Skip to content

Determining visible item count #220

Answered by piecyk
cmlenz asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, yes. You can read visible range start/end via rangeExtractor, something like

import { useVirtual, defaultRangeExtractor } from 'react-virtual'

function App() {
  const parentRef = React.useRef(null)
  const rangeRef = React.useRef({ start: 0, end: 0 })

  const rowVirtualizer = useVirtual({
    size: 1000,
    parentRef,
    rangeExtractor: React.useCallback(range => {
      rangeRef.current = range

      return defaultRangeExtractor(range)
    }, []),
  })
  
  // ...
}

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@cmlenz
Comment options

Answer selected by cmlenz
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants