Add useVirtualList hook
We need to add a new hook called useVirtualList to @siberiacancode/reactuse.
The hook should virtualize the rendering of large lists. Instead of mounting every item, it renders only the items currently visible inside a scrollable container (plus a small overscan buffer), which solves slow first render and janky scrolling when displaying massive amounts of data. It should be useful for long feeds, tables, chat history, search results, and any case where thousands of rows need to be rendered.
What needs to be done
- Create a new hook directory inside the hooks package:
packages/hooks/src/useVirtualList
- Add the hook implementation:
- Add unit tests:
- Add a demo/example component for the documentation.
- Export the hook from the package entry point so it is available from:
import { useVirtualList } from '@siberiacancode/reactuse';
- Make sure the hook is SSR-compatible.
Do not access window, document, or other browser-only APIs at module level.
Add
useVirtualListhookWe need to add a new hook called
useVirtualListto@siberiacancode/reactuse.The hook should virtualize the rendering of large lists. Instead of mounting every item, it renders only the items currently visible inside a scrollable container (plus a small overscan buffer), which solves slow first render and janky scrolling when displaying massive amounts of data. It should be useful for long feeds, tables, chat history, search results, and any case where thousands of rows need to be rendered.
What needs to be done
Do not access
window,document, or other browser-only APIs at module level.