Skip to content

Export useCachedBounds hook as part of public API#867

Closed
bvaughn wants to merge 1 commit intomasterfrom
get-bounds-api-alt
Closed

Export useCachedBounds hook as part of public API#867
bvaughn wants to merge 1 commit intomasterfrom
get-bounds-api-alt

Conversation

@bvaughn
Copy link
Owner

@bvaughn bvaughn commented Oct 9, 2025

Possible alternative to #866

import { List, useCachedBounds } from "react-window";

function Example({ items }) {
  const cachedBounds = useCachedBounds({
    itemCount: items.length,
    itemProps: { items },
    itemSize: 25,
  });

  const rowHeightFunction = useCallback((index:number)=> {
    return cachedBounds.get(index).size;
  },[cachedBounds])

  return <List
    rowCount={items.length}
    rowHeight={rowHeightFunction}
    rowProps={{ items }}
    {...rest}
  />

  // ...
}

@vercel
Copy link

vercel bot commented Oct 9, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
react-window Ready Ready Preview Oct 9, 2025 2:00am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant