{"id":13494686,"url":"https://github.com/danbovey/react-infinite-scroller","last_synced_at":"2025-09-27T08:30:32.511Z","repository":{"id":37640745,"uuid":"53362295","full_name":"danbovey/react-infinite-scroller","owner":"danbovey","description":"⏬ Infinite scroll component for React in ES6","archived":false,"fork":true,"pushed_at":"2024-02-21T11:48:23.000Z","size":1965,"stargazers_count":3299,"open_issues_count":98,"forks_count":511,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-01-12T10:46:33.425Z","etag":null,"topics":["infinite-scroll","react","react-component"],"latest_commit_sha":null,"homepage":"https://danbovey.uk/react-infinite-scroller/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"guillaumervls/react-infinite-scroll","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danbovey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-07T22:00:06.000Z","updated_at":"2025-01-10T02:23:10.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/danbovey/react-infinite-scroller","commit_stats":null,"previous_names":["cassetterocks/react-infinite-scroller"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danbovey%2Freact-infinite-scroller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danbovey%2Freact-infinite-scroller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danbovey%2Freact-infinite-scroller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danbovey%2Freact-infinite-scroller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danbovey","download_url":"https://codeload.github.com/danbovey/react-infinite-scroller/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234410478,"owners_count":18828212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["infinite-scroll","react","react-component"],"created_at":"2024-07-31T19:01:27.206Z","updated_at":"2025-09-27T08:30:26.822Z","avatar_url":"https://github.com/danbovey.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# React Infinite Scroller\n\n[![npm](https://img.shields.io/npm/dt/react-infinite-scroller.svg?style=flat-square)](https://www.npmjs.com/package/react-infinite-scroller)\n[![npm](https://img.shields.io/npm/v/react-infinite-scroller.svg?style=flat-square)](https://www.npmjs.com/package/react-infinite-scroller)\n[![npm](https://img.shields.io/npm/l/react-infinite-scroller.svg?style=flat-square)](https://github.com/danbovey/react-infinite-scroller/blob/master/LICENSE)\n\nInfinitely 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.\n\n- ⏬ Ability to use window or a scrollable element\n- 📏 No need to specify item heights\n- 💬 Support for \"chat history\" (reverse) mode\n- ✅ Fully unit tested and used in hundreds of production sites around the\n  world!\n- 📦 Lightweight alternative to other available React scroll libs ~ 2.2KB\n  minified \u0026 gzipped\n\n---\n\n- [Demo](https://danbovey.uk/react-infinite-scroller/demo/)\n- [Demo Source](https://github.com/danbovey/react-infinite-scroller/blob/master/docs/src/index.js)\n\n## Installation\n\n```\nnpm install react-infinite-scroller --save\n```\n```\nyarn add react-infinite-scroller\n```\n\n## How to use\n\n```js\nimport InfiniteScroll from 'react-infinite-scroller';\n```\n\n### Window scroll events\n\n```js\n\u003cInfiniteScroll\n    pageStart={0}\n    loadMore={loadFunc}\n    hasMore={true || false}\n    loader={\u003cdiv className=\"loader\" key={0}\u003eLoading ...\u003c/div\u003e}\n\u003e\n    {items} // \u003c-- This is the content you want to load\n\u003c/InfiniteScroll\u003e\n```\n\n### DOM scroll events\n\n```js\n\u003cdiv style=\"height:700px;overflow:auto;\"\u003e\n    \u003cInfiniteScroll\n        pageStart={0}\n        loadMore={loadFunc}\n        hasMore={true || false}\n        loader={\u003cdiv className=\"loader\" key={0}\u003eLoading ...\u003c/div\u003e}\n        useWindow={false}\n    \u003e\n        {items}\n    \u003c/InfiniteScroll\u003e\n\u003c/div\u003e\n```\n\n### Custom parent element\n\nYou can define a custom `parentNode` element to base the scroll calulations on.\n\n```js\n\u003cdiv style=\"height:700px;overflow:auto;\" ref={(ref) =\u003e this.scrollParentRef = ref}\u003e\n    \u003cdiv\u003e\n        \u003cInfiniteScroll\n            pageStart={0}\n            loadMore={loadFunc}\n            hasMore={true || false}\n            loader={\u003cdiv className=\"loader\" key={0}\u003eLoading ...\u003c/div\u003e}\n            useWindow={false}\n            getScrollParent={() =\u003e this.scrollParentRef}\n        \u003e\n            {items}\n        \u003c/InfiniteScroll\u003e\n    \u003c/div\u003e\n\u003c/div\u003e\n```\n\n## Props\n\n| Name              | Required | Type         | Default   | Description                                                                                                                                                                         |\n| :---------------- | :------- | :----------- | :-------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `children`        | Yes      | `Node`   |           | Anything that can be rendered (same as PropType's Node) |\n| `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 */ }` } |\n| `element`         |          | `Component`  | `'div'`   | Name of the element that the component should render as.                                                                                                                            |\n| `hasMore`         |          | `Boolean`    | `false`   | Whether there are more items to be loaded. Event listeners are removed if `false`.                                                                                                  |\n| `initialLoad`     |          | `Boolean`    | `true`    | Whether the component should load the first set of items.                                                                                                                           |\n| `isReverse`       |          | `Boolean`    | `false`   | Whether new items should be loaded when user scrolls to the top of the scrollable area.                                                                                             |\n| `loader`          |          | `Component`  |           | A React component to render while more items are loading. The parent component must have a unique key prop.                                                                         |\n| `pageStart`       |          | `Number`     | `0`       | The number of the first page to load, With the default of `0`, the first page is `1`.                                                                                               |\n| `getScrollParent` |          | `Function`   |           | Override method to return a different scroll listener if it's not the immediate parent of InfiniteScroll.                                                                           |\n| `threshold`       |          | `Number`     | `250`     | The distance in pixels before the end of the items that will trigger a call to `loadMore`.                                                                                          |\n| `useCapture`      |          | `Boolean`    | `false`   | Proxy to the `useCapture` option of the added event listeners.                                                                                                                      |\n| `useWindow`       |          | `Boolean`    | `true`    | Add scroll listeners to the window, or else, the component's `parentNode`.                                                                                                          |\n\n## Troubleshooting\n\n### Double or non-stop calls to `loadMore`\n\nIf you experience double or non-stop calls to your `loadMore` callback, make\nsure you have your CSS layout working properly before adding this component in.\nCalculations are made based on the height of the container (the element the\ncomponent creates to wrap the items), so the height of the container must equal\nthe entire height of the items.\n\n```css\n.my-container {\n  overflow: auto;\n}\n```\n\nSome people have found success using [react-infinite-scroll-component](https://github.com/ankeetmaini/react-infinite-scroll-component).\n\n### But you should just add an `isLoading` prop!\n\nThis component doesn't make any assumptions about what you do in terms of API\ncalls. It's up to you to store whether you are currently loading items from an\nAPI in your state/reducers so that you don't make overlapping API calls.\n\n```js\nloadMore() {\n  if(!this.state.isLoading) {\n    this.props.fetchItems();\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanbovey%2Freact-infinite-scroller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanbovey%2Freact-infinite-scroller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanbovey%2Freact-infinite-scroller/lists"}