All Projects → danbovey → react-infinite-scroller

danbovey / react-infinite-scroller

Licence: MIT license
⏬ Infinite scroll component for React in ES6

Projects that are alternatives of or similar to react-infinite-scroller

React-Limited-Infinite-Scroll
A limited infinite scroll component for React(React有限无限加载组件)
Stars: ✭ 37 (-98.79%)
Mutual labels:  react-component, infinite-scroll
react-example-paginated-list-infinite-scroll
Follow a React tutorial series with three parts to build a powerful component in React.
Stars: ✭ 43 (-98.6%)
Mutual labels:  react-component, infinite-scroll
react-tabllist
React-based customizable style table or list components that support event and callback functions.
Stars: ✭ 20 (-99.35%)
Mutual labels:  react-component, infinite-scroll
infinite-carousel-flutter
Carousel in flutter. Supports infinite looping and gives control over anchor and velocity.
Stars: ✭ 24 (-99.22%)
Mutual labels:  infinite-scroll
react-dates
An easily internationalizable, mobile-friendly datepicker library for the web
Stars: ✭ 12,032 (+292.69%)
Mutual labels:  react-component
react-native-slider-intro
A simple and fully customizable React Native component that implements an intro slider for your app
Stars: ✭ 80 (-97.39%)
Mutual labels:  react-component
react-simple-image-slider
simple image slider component for react
Stars: ✭ 127 (-95.86%)
Mutual labels:  react-component
react-grid
react grid component
Stars: ✭ 17 (-99.45%)
Mutual labels:  react-component
react-mathjax-preview
The MathJax React component you were looking for.
Stars: ✭ 46 (-98.5%)
Mutual labels:  react-component
react-ignore-rerender
🚀 Simple component for ignoring the re-rendering of a piece of React's render method.
Stars: ✭ 28 (-99.09%)
Mutual labels:  react-component
react-tags-input
[Not Actively Maintained] An input control that handles tags interaction with copy-paste and custom type support.
Stars: ✭ 26 (-99.15%)
Mutual labels:  react-component
angular-search-experience
Algolia + Angular = 🔥🔥🔥
Stars: ✭ 166 (-94.58%)
Mutual labels:  infinite-scroll
vue-data-loading
Another component for infinite scroll and pull down/up to load data.
Stars: ✭ 63 (-97.94%)
Mutual labels:  infinite-scroll
scrollbox
A lightweight jQuery custom scrollbar plugin, that triggers event when reached the defined point.
Stars: ✭ 15 (-99.51%)
Mutual labels:  infinite-scroll
tiny-ui
⚛️ A friendly UI component set for React.js
Stars: ✭ 202 (-93.41%)
Mutual labels:  react-component
react-timer-wrapper
Composable React Timer component that passes status props to children, in addition to some basic callbacks. Can be used at a countdown timer ⏲ or as stopwatch ⏱ to track time while active.
Stars: ✭ 14 (-99.54%)
Mutual labels:  react-component
react-multiselect-two-sides
React multiselect two sides component
Stars: ✭ 15 (-99.51%)
Mutual labels:  react-component
react-textarea-code-editor
A simple code editor with syntax highlighting.
Stars: ✭ 247 (-91.94%)
Mutual labels:  react-component
git-issue-react-electronjs
⚙️. ⚛️. A desktop application created with Electronjs and Reactjs to be cross-platform to manage and track GitHub issues.
Stars: ✭ 21 (-99.31%)
Mutual labels:  react-component
react-file-input
⚛️  A file Input, with drag'n'drop and image editor for React
Stars: ✭ 71 (-97.68%)
Mutual labels:  react-component

React Infinite Scroller

npm npm npm

Infinitely load a grid or list of items in React. This component allows you to create a simple, lightweight infinite scrolling page or element by supporting both window and scrollable elements.

  • Ability to use window or a scrollable element
  • 📏 No need to specify item heights
  • 💬 Support for "chat history" (reverse) mode
  • Fully unit tested and used in hundreds of production sites around the world!
  • 📦 Lightweight alternative to other available React scroll libs ~ 2.2KB minified & gzipped

Installation

npm install react-infinite-scroller --save
yarn add react-infinite-scroller

How to use

import InfiniteScroll from 'react-infinite-scroller';

Window scroll events

<InfiniteScroll
    pageStart={0}
    loadMore={loadFunc}
    hasMore={true || false}
    loader={<div className="loader" key={0}>Loading ...</div>}
>
    {items} // <-- This is the content you want to load
</InfiniteScroll>

DOM scroll events

<div style="height:700px;overflow:auto;">
    <InfiniteScroll
        pageStart={0}
        loadMore={loadFunc}
        hasMore={true || false}
        loader={<div className="loader" key={0}>Loading ...</div>}
        useWindow={false}
    >
        {items}
    </InfiniteScroll>
</div>

Custom parent element

You can define a custom parentNode element to base the scroll calulations on.

<div style="height:700px;overflow:auto;" ref={(ref) => this.scrollParentRef = ref}>
    <div>
        <InfiniteScroll
            pageStart={0}
            loadMore={loadFunc}
            hasMore={true || false}
            loader={<div className="loader" key={0}>Loading ...</div>}
            useWindow={false}
            getScrollParent={() => this.scrollParentRef}
        >
            {items}
        </InfiniteScroll>
    </div>
</div>

Props

Name Required Type Default Description
children       Yes Node             Anything that can be rendered (same as PropType's Node)
loadMore       Yes Function             A callback when more items are requested by the user. Receives a single parameter specifying the page to load e.g. function handleLoadMore(page) { /* load more items here */ } }
element Component 'div' Name of the element that the component should render as.
hasMore Boolean false Whether there are more items to be loaded. Event listeners are removed if false.
initialLoad Boolean true Whether the component should load the first set of items.
isReverse Boolean false Whether new items should be loaded when user scrolls to the top of the scrollable area.
loader Component A React component to render while more items are loading. The parent component must have a unique key prop.
pageStart Number 0 The number of the first page to load, With the default of 0, the first page is 1.
getScrollParent Function Override method to return a different scroll listener if it's not the immediate parent of InfiniteScroll.
threshold Number 250 The distance in pixels before the end of the items that will trigger a call to loadMore.
useCapture Boolean false Proxy to the useCapture option of the added event listeners.
useWindow Boolean true Add scroll listeners to the window, or else, the component's parentNode.

Troubleshooting

Double or non-stop calls to loadMore

If you experience double or non-stop calls to your loadMore callback, make sure you have your CSS layout working properly before adding this component in. Calculations are made based on the height of the container (the element the component creates to wrap the items), so the height of the container must equal the entire height of the items.

.my-container {
  overflow: auto;
}

Some people have found success using react-infinite-scroll-component.

But you should just add an isLoading prop!

This component doesn't make any assumptions about what you do in terms of API calls. It's up to you to store whether you are currently loading items from an API in your state/reducers so that you don't make overlapping API calls.

loadMore() {
  if(!this.state.isLoading) {
    this.props.fetchItems();
  }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].