react-infinite-scroll-component vs react-infinite-scroller vs react-window-infinite-loader
React 無限スクロール実装の技術比較
react-infinite-scroll-componentreact-infinite-scrollerreact-window-infinite-loader類似パッケージ:

React 無限スクロール実装の技術比較

react-infinite-scroll-componentreact-infinite-scrollerreact-window-infinite-loader は、React アプリケーションで無限スクロール機能を実装するためのライブラリです。これらは大量のデータを効率的に表示し、ユーザーがスクロールするたびに新しいデータを読み込む仕組みを提供しますが、アプローチと性能特性が異なります。react-infinite-scroll-component はシンプルさを重視し、react-infinite-scroller は軽量な実装を提供し、react-window-infinite-loaderreact-window と連携して仮想化による高性能を実現します。

npmのダウンロードトレンド

3 年

GitHub Starsランキング

統計詳細

パッケージ
ダウンロード数
Stars
サイズ
Issues
公開日時
ライセンス
react-infinite-scroll-component03,074155 kB1511日前MIT
react-infinite-scroller03,30530.3 kB98-MIT
react-window-infinite-loader095123 kB03ヶ月前MIT

React 無限スクロールライブラリ:性能、実装、アーキテクチャ比較

react-infinite-scroll-componentreact-infinite-scrollerreact-window-infinite-loader は、React で無限スクロールを実装する代表的なライブラリですが、根本的なアプローチが異なります。実際の開発現場で直面する問題にどう対応するか、技術的な観点から比較します。

🏗️ 基本アーキテクチャ:仮想化の有無

react-infinite-scroll-component は DOM にすべてのアイテムをレンダリングします。

  • 実装がシンプルで理解しやすい
  • 数据量が増えるとパフォーマンスが低下
  • 検索やフィルタリングが容易
// react-infinite-scroll-component: 全アイテムをレンダリング
import InfiniteScroll from 'react-infinite-scroll-component';

function UserList({ users, fetchMore, hasMore }) {
  return (
    <InfiniteScroll
      dataLength={users.length}
      next={fetchMore}
      hasMore={hasMore}
      loader={<h4>読み込み中...</h4>}
    >
      {users.map(user => (
        <div key={user.id}>{user.name}</div>
      ))}
    </InfiniteScroll>
  );
}

react-infinite-scroller も同様に全アイテムをレンダリングします。

  • 依存関係が軽量
  • window スクロールと要素スクロールの両方をサポート
  • 大規模データには非推奨
// react-infinite-scroller: 全アイテムをレンダリング
import InfiniteScroll from 'react-infinite-scroller';

function UserList({ users, fetchMore, hasMore }) {
  return (
    <InfiniteScroll
      pageStart={0}
      loadMore={fetchMore}
      hasMore={hasMore}
      loader={<div key={0}>読み込み中...</div>}
    >
      {users.map(user => (
        <div key={user.id}>{user.name}</div>
      ))}
    </InfiniteScroll>
  );
}

react-window-infinite-loader は仮想化を使用して表示中のアイテムのみをレンダリングします。

  • react-window と連携して高性能を実現
  • 数千件のデータでもスムーズに動作
  • 実装の複雑さが増加
// react-window-infinite-loader: 仮想化で表示中のみのレンダリング
import InfiniteLoader from 'react-window-infinite-loader';
import { FixedSizeList } from 'react-window';

function UserList({ users, fetchMore, hasMore }) {
  const isItemLoaded = index => !hasMore || index < users.length;
  
  return (
    <InfiniteLoader
      isItemLoaded={isItemLoaded}
      itemCount={hasMore ? users.length + 1 : users.length}
      loadMoreItems={fetchMore}
    >
      {({ onItemsRendered, ref }) => (
        <FixedSizeList
          height={600}
          itemCount={users.length}
          itemSize={50}
          onItemsRendered={onItemsRendered}
          ref={ref}
        >
          {({ index, style }) => (
            <div style={style} key={users[index]?.id}>
              {users[index]?.name || '読み込み中...'}
            </div>
          )}
        </FixedSizeList>
      )}
    </InfiniteLoader>
  );
}

📊 データ管理:状態の持ち方

データの状態管理方法もライブラリ間で異なります。

react-infinite-scroll-component は親コンポーネントで状態を管理します。

  • dataLength props で現在のアイテム数を通知
  • 状態管理の責任は開発者に委ねられる
  • Redux や Context との統合が容易
// react-infinite-scroll-component: 親で状態管理
function UserList() {
  const [users, setUsers] = useState([]);
  const [page, setPage] = useState(1);
  
  const fetchMore = async () => {
    const newUsers = await api.getUsers(page + 1);
    setUsers([...users, ...newUsers]);
    setPage(page + 1);
  };
  
  return (
    <InfiniteScroll
      dataLength={users.length}
      next={fetchMore}
      hasMore={users.length < total}
    >
      {users.map(user => <UserCard key={user.id} user={user} />)}
    </InfiniteScroll>
  );
}

react-infinite-scroller も同様に親コンポーネントで状態を管理します。

  • pageStart で現在のページを追跡
  • 古い API 設計(クラスコンポーネント時代の名残り)
// react-infinite-scroller: 親で状態管理
function UserList() {
  const [users, setUsers] = useState([]);
  const [page, setPage] = useState(0);
  
  const fetchMore = async () => {
    const newUsers = await api.getUsers(page + 1);
    setUsers([...users, ...newUsers]);
    setPage(page + 1);
  };
  
  return (
    <InfiniteScroll
      pageStart={page}
      loadMore={fetchMore}
      hasMore={users.length < total}
    >
      {users.map(user => <UserCard key={user.id} user={user} />)}
    </InfiniteScroll>
  );
}

react-window-infinite-loader はアイテムのロード状態をライブラリが管理します。

  • isItemLoaded で各アイテムのロード状態を判定
  • loadMoreItems がバッチ処理をサポート
  • より細かい制御が可能
// react-window-infinite-loader: ライブラリがロード状態を管理
function UserList() {
  const [users, setUsers] = useState({});
  
  const isItemLoaded = index => users[index] !== undefined;
  
  const loadMoreItems = async ({ startIndex, stopIndex }) => {
    const newUsers = await api.getUsers(startIndex, stopIndex);
    setUsers(prev => ({ ...prev, ...newUsers }));
  };
  
  return (
    <InfiniteLoader
      isItemLoaded={isItemLoaded}
      itemCount={total}
      loadMoreItems={loadMoreItems}
    >
      {({ onItemsRendered, ref }) => (
        <FixedSizeList
          height={600}
          itemCount={total}
          itemSize={50}
          onItemsRendered={onItemsRendered}
          ref={ref}
        >
          {({ index, style }) => (
            <div style={style} key={index}>
              {users[index]?.name || '読み込み中...'}
            </div>
          )}
        </FixedSizeList>
      )}
    </InfiniteLoader>
  );
}

⚡ パフォーマンス特性:描画コストとメモリ使用量

パフォーマンスは無限スクロール実装で最も重要な考慮事項です。

react-infinite-scroll-component のパフォーマンス特性:

  • 1000 件程度までは問題なく動作
  • 5000 件を超えるとスクロールが重くなる可能性
  • メモリ使用量がデータ量に比例して増加
  • シンプルな実装のためオーバーヘッドが少ない
// react-infinite-scroll-component: 大量データでの注意点
function UserList() {
  const [users, setUsers] = useState([]);
  
  // ⚠️ 10000 件を超えるとパフォーマンス低下のリスク
  const fetchMore = async () => {
    if (users.length > 5000) {
      console.warn('パフォーマンス低下の可能性があります');
    }
    const newUsers = await api.getUsers(users.length);
    setUsers([...users, ...newUsers]);
  };
  
  return (
    <InfiniteScroll
      dataLength={users.length}
      next={fetchMore}
      hasMore={true}
      scrollThreshold={0.9} // 90% スクロールでトリガー
    >
      {users.map(user => <UserCard key={user.id} user={user} />)}
    </InfiniteScroll>
  );
}

react-infinite-scroller のパフォーマンス特性:

  • react-infinite-scroll-component と同様の制限
  • 追加の機能が少ない分、若干軽量
  • 長期的なメンテナンスに懸念
// react-infinite-scroller: 性能制限への対応
function UserList() {
  const [users, setUsers] = useState([]);
  
  const fetchMore = async () => {
    // ⚠️ 大量データでは仮想化ライブラリの使用を検討
    if (users.length > 3000) {
      console.warn('react-window-infinite-loader への移行を検討してください');
    }
    const newUsers = await api.getUsers(users.length);
    setUsers([...users, ...newUsers]);
  };
  
  return (
    <InfiniteScroll
      pageStart={0}
      loadMore={fetchMore}
      hasMore={users.length < total}
      useWindow={true} // window スクロールを使用
    >
      {users.map(user => <UserCard key={user.id} user={user} />)}
    </InfiniteScroll>
  );
}

react-window-infinite-loader のパフォーマンス特性:

  • 表示中のアイテム(通常 20〜50 件)のみをレンダリング
  • 10 万件以上のデータでもスムーズに動作
  • メモリ使用量が一定に保たれる
  • 初期設定のオーバーヘッドがある
// react-window-infinite-loader: 大規模データに最適化
function UserList() {
  const [users, setUsers] = useState({});
  const TOTAL_ITEMS = 100000;
  
  const isItemLoaded = index => users[index] !== undefined;
  
  const loadMoreItems = async ({ startIndex, stopIndex }) => {
    // バッチ処理で効率的にデータ取得
    const newUsers = await api.getUsersBatch(startIndex, stopIndex);
    setUsers(prev => ({ ...prev, ...newUsers }));
  };
  
  return (
    <InfiniteLoader
      isItemLoaded={isItemLoaded}
      itemCount={TOTAL_ITEMS}
      loadMoreItems={loadMoreItems}
      minimumBatchSize={10} // 一度にロードする最小アイテム数
    >
      {({ onItemsRendered, ref }) => (
        <FixedSizeList
          height={600}
          itemCount={TOTAL_ITEMS}
          itemSize={50}
          onItemsRendered={onItemsRendered}
          ref={ref}
          overscanCount={5} // 表示範囲外のバッファ
        >
          {({ index, style }) => (
            <div style={style} key={index}>
              {users[index]?.name || '読み込み中...'}
            </div>
          )}
        </FixedSizeList>
      )}
    </InfiniteLoader>
  );
}

🔄 スクロール位置の保持:ページ遷移後の復元

実務ではページ遷移後にスクロール位置を保持する必要がある場合があります。

react-infinite-scroll-component はスクロール位置の保持が容易です。

  • 標準的な DOM 要素として動作
  • scrollTop を直接制御可能
  • 履歴管理との統合が簡単
// react-infinite-scroll-component: スクロール位置保持
function UserList() {
  const scrollRef = useRef(null);
  const [scrollPosition, setScrollPosition] = useState(0);
  
  useEffect(() => {
    if (scrollRef.current) {
      scrollRef.current.scrollTop = scrollPosition;
    }
  }, []);
  
  const handleScroll = () => {
    if (scrollRef.current) {
      setScrollPosition(scrollRef.current.scrollTop);
    }
  };
  
  return (
    <div
      ref={scrollRef}
      onScroll={handleScroll}
      style={{ height: '600px', overflow: 'auto' }}
    >
      <InfiniteScroll
        dataLength={users.length}
        next={fetchMore}
        hasMore={hasMore}
        scrollableTarget={scrollRef.current}
      >
        {users.map(user => <UserCard key={user.id} user={user} />)}
      </InfiniteScroll>
    </div>
  );
}

react-infinite-scroller も同様にスクロール位置を制御できます。

  • useWindow props で window/要素スクロールを切り替え
  • 要素スクロールの場合、getScrollParent で制御
// react-infinite-scroller: スクロール位置保持
function UserList() {
  const containerRef = useRef(null);
  
  useEffect(() => {
    if (containerRef.current) {
      containerRef.current.scrollTop = savedPosition;
    }
  }, []);
  
  return (
    <div ref={containerRef} style={{ height: '600px', overflow: 'auto' }}>
      <InfiniteScroll
        pageStart={0}
        loadMore={fetchMore}
        hasMore={hasMore}
        useWindow={false} // 要素スクロールを使用
        getScrollParent={() => containerRef.current}
      >
        {users.map(user => <UserCard key={user.id} user={user} />)}
      </InfiniteScroll>
    </div>
  );
}

react-window-infinite-loader は仮想化のためスクロール位置の制御が特殊です。

  • scrollToItem メソッドを使用
  • インデックスベースで位置を指定
  • 復元時にアイテムがロードされている必要がある
// react-window-infinite-loader: スクロール位置保持
function UserList() {
  const listRef = useRef(null);
  const targetIndex = useRef(0);
  
  useEffect(() => {
    if (listRef.current && targetIndex.current > 0) {
      listRef.current.scrollToItem(targetIndex.current, 'start');
    }
  }, [users]);
  
  return (
    <InfiniteLoader
      isItemLoaded={isItemLoaded}
      itemCount={total}
      loadMoreItems={loadMoreItems}
    >
      {({ onItemsRendered, ref }) => (
        <FixedSizeList
          height={600}
          itemCount={total}
          itemSize={50}
          onItemsRendered={onItemsRendered}
          ref={listRef}
        >
          {({ index, style }) => (
            <div style={style} key={index}>
              {users[index]?.name || '読み込み中...'}
            </div>
          )}
        </FixedSizeList>
      )}
    </InfiniteLoader>
  );
}

🎨 UI カスタマイズ:ローダーとエンド表示

ローディング状態や終了時の表示も重要な UX 要素です。

react-infinite-scroll-component のカスタマイズ:

  • loader props でローディング表示を指定
  • endMessage props で終了メッセージを表示
  • 完全に制御可能
// react-infinite-scroll-component: UI カスタマイズ
<InfiniteScroll
  dataLength={users.length}
  next={fetchMore}
  hasMore={hasMore}
  loader={
    <div className="loader">
      <Spinner />
      <p>データを読み込んでいます...</p>
    </div>
  }
  endMessage={
    <div className="end-message">
      <p>🎉 全てのデータを表示しました</p>
    </div>
  }
  pullDownToRefresh={true}
  refreshFunction={handleRefresh}
>
  {users.map(user => <UserCard key={user.id} user={user} />)}
</InfiniteScroll>

react-infinite-scroller のカスタマイズ:

  • loader props でローディング表示を指定
  • 終了メッセージは自分で実装が必要
  • シンプルな構造
// react-infinite-scroller: UI カスタマイズ
<InfiniteScroll
  pageStart={0}
  loadMore={fetchMore}
  hasMore={hasMore}
  loader={
    <div className="loader" key={0}>
      <Spinner />
      <p>データを読み込んでいます...</p>
    </div>
  }
>
  {users.map(user => <UserCard key={user.id} user={user} />)}
  {!hasMore && (
    <div className="end-message" key="end">
      <p>🎉 全てのデータを表示しました</p>
    </div>
  )}
</InfiniteScroll>

react-window-infinite-loader のカスタマイズ:

  • ローディング状態はアイテムレベルで管理
  • 終了表示は自分で実装が必要
  • より細かい制御が可能
// react-window-infinite-loader: UI カスタマイズ
<InfiniteLoader
  isItemLoaded={isItemLoaded}
  itemCount={hasMore ? users.length + 1 : users.length}
  loadMoreItems={fetchMore}
>
  {({ onItemsRendered, ref }) => (
    <FixedSizeList
      height={600}
      itemCount={hasMore ? users.length + 1 : users.length}
      itemSize={50}
      onItemsRendered={onItemsRendered}
      ref={ref}
    >
      {({ index, style }) => {
        if (index >= users.length) {
          return (
            <div style={style} key="loader">
              <Spinner />
              <p>データを読み込んでいます...</p>
            </div>
          );
        }
        return (
          <div style={style} key={users[index].id}>
            <UserCard user={users[index]} />
          </div>
        );
      }}
    </FixedSizeList>
  )}
</InfiniteLoader>

🌐 共通点:3 ライブラリの共有機能

これらのライブラリには多くの共通点もあります。

1. ⚛️ React コンポーネントとして実装

  • すべて関数コンポーネントまたはクラスコンポーネントとして使用可能
  • React のライフサイクルと統合
  • Hooks との併用が可能
// 3 ライブラリ共通:React コンポーネントとして使用
function UserList({ users, fetchMore, hasMore }) {
  // どのライブラリでも同様のパターンで使用可能
  return (
    <InfiniteScrollComponent
      // 各ライブラリの props を設定
    >
      {users.map(user => <UserCard key={user.id} user={user} />)}
    </InfiniteScrollComponent>
  );
}

2. 📱 両方向スクロールサポート

  • window スクロールと要素スクロールの両方をサポート
  • useWindow または scrollableTarget で制御
  • モバイルデバイスでも動作
// window スクロールの場合
<InfiniteScroll useWindow={true}>
  {/* 内容 */}
</InfiniteScroll>

// 要素スクロールの場合
<div style={{ height: '600px', overflow: 'auto' }}>
  <InfiniteScroll useWindow={false}>
    {/* 内容 */}
  </InfiniteScroll>
</div>

3. 🔄 非同期データ読み込み

  • nextloadMoreloadMoreItems でデータ取得をトリガー
  • Promise ベースの非同期処理をサポート
  • エラーハンドリングは開発者側で実装
// 3 ライブラリ共通:非同期データ読み込みパターン
const fetchMore = async () => {
  try {
    const newItems = await api.getData(page);
    setItems([...items, ...newItems]);
  } catch (error) {
    console.error('データ取得エラー:', error);
    // エラー状態の管理は開発者側で
  }
};

4. ✅ TypeScript サポート

  • すべて TypeScript 定義ファイルを提供
  • 型安全性を確保可能
  • IDE での補完が利用可能
// TypeScript での使用例(3 ライブラリ共通)
interface User {
  id: number;
  name: string;
}

interface Props {
  users: User[];
  fetchMore: () => Promise<void>;
  hasMore: boolean;
}

function UserList({ users, fetchMore, hasMore }: Props) {
  // 型チェックが機能
}

5. 🎯 スクロールトリガー閾値

  • スクロール位置の閾値を設定可能
  • 早期にデータを読み込むことで UX を向上
  • scrollThreshold props で制御
// スクロール閾値の設定(対応ライブラリ)
<InfiniteScroll
  scrollThreshold={0.8} // 80% スクロールでトリガー
  // 早期読み込みでユーザー待機時間を削減
>
  {/* 内容 */}
</InfiniteScroll>

📊 比較サマリー表

機能react-infinite-scroll-componentreact-infinite-scrollerreact-window-infinite-loader
仮想化❌ 全アイテムレンダリング❌ 全アイテムレンダリング✅ 表示中のみのレンダリング
最大推奨アイテム数~1000 件~1000 件10 万件以上
メモリ使用量データ量に比例データ量に比例一定
実装の複雑さ中〜高
スクロール位置保持容易容易特殊な制御が必要
メンテナンス状況活発要注意活発
依存関係軽量軽量react-window が必要

💡 最終推奨

データ量とパフォーマンス要件で選択しましょう:

  • 1000 件未満のリストreact-infinite-scroll-component(シンプルで十分)
  • 既存プロジェクトの維持react-infinite-scroller(変更コストを考慮)
  • 1000 件以上の大規模データreact-window-infinite-loader(性能が最優先)
  • エンタープライズアプリケーションreact-window-infinite-loader(安定性と拡張性)

重要なポイント:無限スクロール実装では、初期の開発速度よりも長期的なパフォーマンスとメンテナンス性を重視すべきです。プロジェクトの規模と成長を見据えて、適切なライブラリを選択しましょう。

選び方: react-infinite-scroll-component vs react-infinite-scroller vs react-window-infinite-loader

  • react-infinite-scroll-component:

    react-infinite-scroll-component を選択するのは、シンプルな実装で十分な場合や、仮想化の複雑さを避けたいプロジェクトです。メンテナンスが活発で API が直感的ですが、大量のデータ(1000 件以上)をレンダリングするとパフォーマンスが低下する可能性があります。小〜中規模のリストや、プロトタイプ開発に適しています。

  • react-infinite-scroller:

    react-infinite-scroller を選択するのは、軽量な依存関係とシンプルな API を優先する場合です。ただし、メンテナンス状況に注意が必要で、新しいプロジェクトでは慎重に評価すべきです。既存プロジェクトの維持や、仮想化が不要なシンプルなユースケースに適しています。

  • react-window-infinite-loader:

    react-window-infinite-loader を選択するのは、大規模なデータセット(数千件以上)を扱う場合や、パフォーマンスが最優先事項の場合です。react-window と連携して仮想化を実現し、表示されているアイテムのみをレンダリングするため、メモリ使用量と描画コストを大幅に削減できます。エンタープライズアプリケーションやデータ密集型プロジェクトに最適です。

react-infinite-scroll-component のREADME

react-infinite-scroll-component npm npm

All Contributors

A component to make all your infinite scrolling woes go away with just 4.15 kB! Pull Down to Refresh feature added. An infinite-scroll that actually works and super-simple to integrate!

Install

  npm install --save react-infinite-scroll-component

  or

  yarn add react-infinite-scroll-component

  // in code ES6
  import InfiniteScroll from 'react-infinite-scroll-component';
  // or commonjs
  var InfiniteScroll = require('react-infinite-scroll-component');

Using

<InfiniteScroll
  dataLength={items.length} //This is important field to render the next data
  next={fetchData}
  hasMore={true}
  loader={<h4>Loading...</h4>}
  endMessage={
    <p style={{ textAlign: 'center' }}>
      <b>Yay! You have seen it all</b>
    </p>
  }
  // below props only if you need pull down functionality
  refreshFunction={refresh}
  pullDownToRefresh
  pullDownToRefreshThreshold={50}
  pullDownToRefreshContent={
    <h3 style={{ textAlign: 'center' }}>&#8595; Pull down to refresh</h3>
  }
  releaseToRefreshContent={
    <h3 style={{ textAlign: 'center' }}>&#8593; Release to refresh</h3>
  }
>
  {items}
</InfiniteScroll>

Using scroll on top

<div
  id="scrollableDiv"
  style={{
    height: 300,
    overflow: 'auto',
    display: 'flex',
    flexDirection: 'column-reverse',
  }}
>
  {/*Put the scroll bar always on the bottom*/}
  <InfiniteScroll
    dataLength={items.length}
    next={fetchMoreData}
    style={{ display: 'flex', flexDirection: 'column-reverse' }} //To put endMessage and loader to the top.
    inverse={true}
    hasMore={true}
    loader={<h4>Loading...</h4>}
    scrollableTarget="scrollableDiv"
  >
    {items.map((_, index) => (
      <div style={style} key={index}>
        div - #{index}
      </div>
    ))}
  </InfiniteScroll>
</div>

The InfiniteScroll component can be used in three ways.

  • Specify a value for the height prop if you want your scrollable content to have a specific height, providing scrollbars for scrolling your content and fetching more data.
  • If your scrollable content is being rendered within a parent element that is already providing overflow scrollbars, you can set the scrollableTarget prop to reference the DOM element and use it's scrollbars for fetching more data.
  • Without setting either the height or scrollableTarget props, the scroll will happen at document.body like Facebook's timeline scroll.

What's new in v7

IntersectionObserver-based triggering

next() is now triggered by an IntersectionObserver watching an invisible sentinel element at the bottom of the list (top for inverse mode), rather than a scroll event listener. This means:

  • The threshold is checked once when the sentinel enters the viewport, not on every scroll tick.
  • No missed triggers when content loads fast enough to skip the threshold.
  • Better performance — no work done while the user is scrolling through content that is far from the threshold.

Zero runtime dependencies

throttle-debounce has been removed. The package now ships with zero runtime dependencies. The onScroll callback receives every scroll event directly without throttling.

scrollableTarget accepts HTMLElement directly

Previously scrollableTarget only accepted a string element ID. It now accepts HTMLElement | string | null, so you can pass a ref value directly:

const ref = useRef(null);
// ...
<div ref={ref} style={{ height: 300, overflow: 'auto' }}>
  <InfiniteScroll scrollableTarget={ref.current} ...>
    {items}
  </InfiniteScroll>
</div>

Rewritten as a function component

The component is now a React function component. The public prop API is unchanged — no migration needed.


docs version wise

3.0.2

live examples

  • infinite scroll (never ending) example using react (body/window scroll)
    • Edit yk7637p62z
  • infinte scroll till 500 elements (body/window scroll)
    • Edit 439v8rmqm0
  • infinite scroll in an element (div of height 400px)
    • Edit w3w89k7x8
  • infinite scroll with scrollableTarget (a parent element which is scrollable)
    • Edit r7rp40n0zm

props

nametypedescription
nextfunctiona function which must be called after reaching the bottom. It must trigger some sort of action which fetches the next data. The data is passed as children to the InfiniteScroll component and the data should contain previous items too. e.g. Initial data = [1, 2, 3] and then next load of data should be [1, 2, 3, 4, 5, 6].
hasMorebooleanit tells the InfiniteScroll component on whether to call next function on reaching the bottom and shows an endMessage to the user
childrennode (list)the data items which you need to scroll.
dataLengthnumberset the length of the data.This will unlock the subsequent calls to next.
loadernodeyou can send a loader component to show while the component waits for the next load of data. e.g. <h3>Loading...</h3> or any fancy loader element
scrollThresholdnumber | stringA threshold value defining when InfiniteScroll will call next. Default value is 0.8. It means the next will be called when user comes below 80% of the total height. If you pass threshold in pixels (scrollThreshold="200px"), next will be called once you scroll at least (100% - scrollThreshold) pixels down.
onScrollfunctiona function that will listen to the scroll event on the scrolling container.
endMessagenodethis message is shown to the user when he has seen all the records which means he's at the bottom and hasMore is false
classNamestringadd any custom class you want
styleobjectany style which you want to override
heightnumberoptional, give only if you want to have a fixed height scrolling content
scrollableTargetnode or stringoptional, reference to a (parent) DOM element that is already providing overflow scrollbars to the InfiniteScroll component. You should provide the id of the DOM node preferably.
hasChildrenboolchildren is by default assumed to be of type array and it's length is used to determine if loader needs to be shown or not, if your children is not an array, specify this prop to tell if your items are 0 or more.
pullDownToRefreshboolto enable Pull Down to Refresh feature
pullDownToRefreshContentnodeany JSX that you want to show the user, default={<h3>Pull down to refresh</h3>}
releaseToRefreshContentnodeany JSX that you want to show the user, default={<h3>Release to refresh</h3>}
pullDownToRefreshThresholdnumberminimum distance the user needs to pull down to trigger the refresh, default=100px , a lower value may be needed to trigger the refresh depending your users browser.
refreshFunctionfunctionthis function will be called, it should return the fresh data that you want to show the user
initialScrollYnumberset a scroll y position for the component to render with.
inverseboolset infinite scroll on top

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Ankeet Maini
Ankeet Maini

💬 📖 💻 👀 🚧
Darsh Shah
Darsh Shah

🚇 💻 👀 🚧
Eliya Cohen
Eliya Cohen

💻
Nitin Kukreja
Nitin Kukreja

💻
Bruno Sabetta
Bruno Sabetta

💻 📖
Osmar Pérez Bautista
Osmar Pérez Bautista

💻
Shreya Dahal
Shreya Dahal

💻
Vlad Harahan
Vlad Harahan

💻 📖
Daniel Caldas
Daniel Caldas

💻
Alaeddine Douagi
Alaeddine Douagi

💻
Carlos
Carlos

💻
Championrunner
Championrunner

📖
Daniel Sogl
Daniel Sogl

💻
Darren Oster
Darren Oster

💻
Illia Panasenko
Illia Panasenko

💻
Kiko Beats
Kiko Beats

💻
Matt Trussler
Matt Trussler

💻
Nimit Suwannagate
Nimit Suwannagate

💻
Rajat
Rajat

💻
Rich
Rich

💻
Ritesh Goyal
Ritesh Goyal

💻
babycannotsay
babycannotsay

💻
cesco
cesco

💻
Harry
Harry

💻
ludwig404
ludwig404

💻
Karl Johansson
Karl Johansson

💻
Geoffrey Teng
Geoffrey Teng

💻

This project follows the all-contributors specification. Contributions of any kind are welcome!

LICENSE

MIT