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

infinite-scroller-react

v0.0.2

Published

A React component for implementing infinite scrolling functionality

Downloads

5

Readme

React Infinite Scroller Component

A highly customizable, TypeScript-based infinite scroll component for React applications with pull-to-refresh functionality.

Features

  • 🔄 Infinite scrolling with customizable threshold
  • ⬇️ Pull-to-refresh support for mobile devices
  • 📱 Custom scrollable container support
  • 🎨 Fully customizable loading and error states
  • 🔧 TypeScript support
  • ⚡ Performance optimized with throttling
  • 🎯 Error boundary integration
  • 📦 Zero dependencies (except React)

Installation

npm install infinite-scroller-react
# or
yarn add infinite-scroller-react

Basic Usage

import { InfiniteScroll } from 'infinite-scroller-react';

function MyComponent() {
  const [items, setItems] = useState([]);
  const [hasMore, setHasMore] = useState(true);
  const [isLoading, setIsLoading] = useState(false);

  const loadMore = async () => {
    setIsLoading(true);
    try {
      const newItems = await fetchMoreItems();
      setItems(prev => [...prev, ...newItems]);
      setHasMore(newItems.length > 0);
    } finally {
      setIsLoading(false);
    }
  };

  return (
    <InfiniteScroll
      loadMore={loadMore}
      hasMore={hasMore}
      isLoading={isLoading}
      loader={<div>Loading...</div>}
    >
      {items.map(item => (
        <div key={item.id}>{item.content}</div>
      ))}
    </InfiniteScroll>
  );
}

Advanced Usage

With Pull-to-Refresh

<InfiniteScroll
  loadMore={loadMore}
  hasMore={hasMore}
  isLoading={isLoading}
  pullDownToRefresh={true}
  pullDownThreshold={100}
  onRefresh={handleRefresh}
  refreshComponent={<div>Pull to refresh...</div>}
  onError={handleError}
>
  {/* Your children content */}
</InfiniteScroll>

With Custom Scrollable Container

<div id="scrollable-container" style={{ height: '500px', overflow: 'auto' }}>
  <InfiniteScroll
    loadMore={loadMore}
    hasMore={hasMore}
    scrollableTarget="scrollable-container"
    threshold={200}
    scrollThrottle={150}
  >
    {/* Your content */}
  </InfiniteScroll>
</div>

Props

| Prop | Type | Required | Default | Description | |------|------|----------|---------|-------------| | loadMore | () => Promise<void> | Yes | - | Function to load more items | | hasMore | boolean | Yes | - | Whether there are more items to load | | isLoading | boolean | No | false | Loading state | | threshold | number | No | 100 | Distance from bottom (in px) to trigger loading | | loader | ReactNode | No | null | Loading indicator component | | className | string | No | - | CSS class for the container | | scrollableTarget | string \| HTMLElement | No | window | Custom scrollable container | | initialLoad | boolean | No | true | Whether to load data on mount | | onError | (error: Error) => void | No | - | Error handler callback | | loadingComponent | ReactNode | No | loader | Custom loading component | | endMessage | ReactNode | No | - | Message shown when no more items | | pullDownToRefresh | boolean | No | false | Enable pull-to-refresh | | pullDownThreshold | number | No | 100 | Pull distance to trigger refresh | | refreshComponent | ReactNode | No | - | Pull-to-refresh indicator | | onRefresh | () => Promise<void> | No | - | Refresh callback function | | scrollThrottle | number | No | 150 | Scroll event throttle in ms |

Best Practices

  1. Error Handling

    const handleError = (error: Error) => {
      console.error('Loading failed:', error);
      // Show user-friendly error message
    };
  2. Loading States

    const LoadingSpinner = () => (
      <div className="loading-spinner">
        <div className="spinner"></div>
        <p>Loading more items...</p>
      </div>
    );
  3. Pull-to-Refresh Implementation

    const handleRefresh = async () => {
      // Reset state
      setPage(1);
      setHasMore(true);
         
      // Fetch fresh data
      const freshData = await fetchData(1);
      setItems(freshData);
    };

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT