JSPM

react-infinite-scroll-loading

0.1.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q19283F
  • License MIT

Infinite scroll component for React.

Package Exports

  • react-infinite-scroll-loading

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-infinite-scroll-loading) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

React Infinite Scroll Loading

Infinite scroll component for React.

Installation and Usage

$ npm i react-infinite-scroll-loading -S
# or
$ yarn add react-infinite-scroll-loading
// for commonjs
const InfiniteScrollLoading = require('react-infinite-scroll-loading');

// for es modules
import InfiniteScrollLoading from 'react-infinite-scroll-loading';

Getting Started

see https://github.com/CassetteRocks/react-infinite-scroller

Reset pageStart number

import InfiniteScrollLoadingLoading from 'react-infinite-scroll-loading';

<InfiniteScrollLoading
  pageStart={0}
  loadMore={loadFunc}
  hasMore={true || false}
  loader={<div className="loader" key={0}>Loading...</div>}
  resetPage={true || false}
>
  {items}
</InfiniteScrollLoading>

Edit red-https-thrgc

Window scroll events

<InfiniteScrollLoading
  pageStart={1}
  hasMore={hasMore && !isLoading}
  loadMore={loadMore}
  resetPage={resetPage}
>
  {
    !!items.length
    && items.map(item => <li key={item.id}>{item.name}</li>)
  }
  {isLoading && <div>Loading...</div>}
</InfiniteScrollLoading>

DOM scroll events

import styled from '@emotion/styled';

const Wrapper = styled('div')`
  height: 660px;
  overflow: auto;
`;

<Wrapper>
  <InfiniteScrollLoading
    pageStart={1}
    hasMore={hasMore && !isLoading}
    loadMore={loadMore}
    resetPage={resetPage}
    useWindow={false}
  >
    {
      !!items.length
      && items.map(item => <li key={item.id}>{item.name}</li>)
    }
    {isLoading && <div>Loading...</div>}
  </InfiniteScrollLoading>
</Wrapper>

Custom parent element

import styled from '@emotion/styled';

const Wrapper = styled('div')`
  height: 660px;
  overflow: auto;
`;

const wrapperRef = useRef();

<Wrapper ref={wrapperRef}>
  <article>
    <InfiniteScrollLoading
      pageStart={1}
      hasMore={hasMore && !isLoading}
      loadMore={loadMore}
      resetPage={resetPage}
      useWindow={false}
      getScrollParent={() => wrapperRef}
    >
      {
        !!items.length
        && items.map(item => <li key={item.id}>{item.name}</li>)
      }
      {isLoading && <div>Loading...</div>}
    </InfiniteScrollLoading>
  </article>

  <aside>...</aside>
</Wrapper>

API

resetPage

Whether the component should reset the page start number.

  • Type: boolean
  • Default: false