npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bongsik/virtual-list

v0.1.2

Published

React hook for virtualized list rendering

Readme

@bongsik/virtual-list

React hook for virtualized list rendering to improve performance with large lists.

Installation

npm install @bongsik/virtual-list
# or
pnpm add @bongsik/virtual-list
# or
yarn add @bongsik/virtual-list

Usage

import { useVirtualList } from "@bongsik/virtual-list";

function MyList() {
  const items = Array.from({ length: 10000 }, (_, i) => `Item ${i}`);

  const {
    virtualItems,
    totalHeight,
    containerStyle,
    handleScroll,
    scrollElementRef,
  } = useVirtualList({
    itemCount: items.length,
    itemHeight: 50, // 고정 높이
    containerHeight: 400,
    overscan: 3,
  });

  return (
    <div ref={scrollElementRef} style={containerStyle} onScroll={handleScroll}>
      <div style={{ height: totalHeight, position: "relative" }}>
        {virtualItems.map((virtualItem) => (
          <div
            key={virtualItem.index}
            style={{
              position: "absolute",
              top: virtualItem.start,
              height: virtualItem.size,
              width: "100%",
            }}
          >
            {items[virtualItem.index]}
          </div>
        ))}
      </div>
    </div>
  );
}

동적 높이 사용

const {
  virtualItems,
  totalHeight,
  containerStyle,
  handleScroll,
  scrollElementRef,
} = useVirtualList({
  itemCount: items.length,
  itemHeight: (index) => {
    // 각 아이템의 높이를 동적으로 계산
    return index % 2 === 0 ? 50 : 80;
  },
  containerHeight: 400,
});

return (
  <div ref={scrollElementRef} style={containerStyle} onScroll={handleScroll}>
    {/* ... */}
  </div>
);

API

useVirtualList(options)

Options

| Property | Type | Default | Description | | ----------------- | --------------------------------------- | ------------- | ----------------------------------------------------------------------------------- | | itemCount | number | required | 전체 아이템 개수 | | itemHeight | number \| ((index: number) => number) | required | 각 아이템의 높이 (px) 또는 높이 계산 함수 | | containerHeight | number | 0 | 컨테이너 높이. containerRefscrollElementRef를 사용하는 경우 선택 | | containerRef | RefObject<HTMLElement> | undefined | 이미 존재하는 컨테이너 요소를 전달할 때 사용 | | overscan | number | 3 | 화면 밖에 렌더링할 추가 아이템 개수 | | scrollOffset | number | 0 | 초기 스크롤 오프셋 (px) 또는 외부 제어 값 | | scrollTarget | "container" \| "window" | "container" | 스크롤을 감지할 대상. window 모드에서는 handleScroll/containerStyle이 필요 없음 |

Returns

| Property | Type | Description | | ------------------ | ------------------------------------------------------ | -------------------------------------------------------------- | | virtualItems | VirtualItem[] | 현재 보이는 가상 아이템들 | | totalHeight | number | 전체 리스트의 총 높이 (px) | | containerStyle | React.CSSProperties | 컨테이너에 적용할 스타일 (scrollTarget === "container"일 때) | | handleScroll | (e: React.UIEvent<HTMLElement>) => void \| undefined | 스크롤 이벤트 핸들러. 컨테이너 모드에서만 제공 | | scrollElementRef | RefObject<HTMLDivElement> | 컨테이너 ref가 없다면 이 ref를 컨테이너에 연결 |

VirtualItem

| Property | Type | Description | | -------- | -------- | ----------------------- | | index | number | 아이템의 인덱스 | | start | number | 아이템의 시작 위치 (px) | | size | number | 아이템의 크기 (px) | | end | number | 아이템의 끝 위치 (px) |

License

MIT