{"id":19686313,"url":"https://github.com/closeio/use-infinite-scroll","last_synced_at":"2025-04-29T06:31:21.895Z","repository":{"id":39188100,"uuid":"249415692","full_name":"closeio/use-infinite-scroll","owner":"closeio","description":"Super simple React hook for creating an infinite scroll experience based on the IntersectionObserver API","archived":false,"fork":false,"pushed_at":"2023-01-05T16:52:00.000Z","size":3134,"stargazers_count":39,"open_issues_count":44,"forks_count":8,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-04-05T13:51:26.760Z","etag":null,"topics":["infinite-scroll","react","react-hooks","react-infinite-scroll","reactjs","use-infinite-scroll"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/closeio.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":"2020-03-23T11:45:04.000Z","updated_at":"2025-03-25T21:48:39.000Z","dependencies_parsed_at":"2023-02-04T07:45:27.116Z","dependency_job_id":null,"html_url":"https://github.com/closeio/use-infinite-scroll","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/closeio%2Fuse-infinite-scroll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/closeio%2Fuse-infinite-scroll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/closeio%2Fuse-infinite-scroll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/closeio%2Fuse-infinite-scroll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/closeio","download_url":"https://codeload.github.com/closeio/use-infinite-scroll/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251450656,"owners_count":21591407,"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-hooks","react-infinite-scroll","reactjs","use-infinite-scroll"],"created_at":"2024-11-11T18:27:22.325Z","updated_at":"2025-04-29T06:31:20.237Z","avatar_url":"https://github.com/closeio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# use-infinite-scroll\n\n[![NPM](https://img.shields.io/npm/v/@closeio/use-infinite-scroll.svg)](https://www.npmjs.com/package/@closeio/use-infinite-scroll) [![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-success)](https://prettier.io)\n\nSuper simple React hook for creating an infinite scroll experience based on the `IntersectionObserver` API.\n\n[Check the live DEMO](https://closeio.github.io/use-infinite-scroll/).\n\n### \u003cimg height=\"40px\" src=\"./close.svg\" /\u003e\n\nInterested in working on projects like this? [Close](https://close.com) is looking for [great engineers](https://jobs.close.com) to join our team!\n\n## Install\n\n```bash\nyarn add @closeio/use-infinite-scroll\n```\n\n## Benefits\n\n- Extremely lightweight (less than 1KB minzipped).\n- It uses the `IntersectionObserver` API, so it doesn't need to listen to `scroll` events – which are known to cause performance issues.\n- No other 3rd-party dependencies.\n\n## Usage\n\n```jsx\nimport React from 'react';\nimport useInfiniteScroll from '@closeio/use-infinite-scroll';\n\nexport default function MyComponent() {\n  const [items, setItems] = useState([]);\n  const [hasMore, setHasMore] = useState(false);\n  const [page, loaderRef, scrollerRef] = useInfiniteScroll({ hasMore });\n\n  useEffect(async () =\u003e {\n    const data = await myApiCall({ page });\n    setHasMore(data.hasMore);\n    setItems(prev =\u003e [...prev, data.items]);\n  }, [page]);\n\n  return (\n    \u003cdiv ref={scrollerRef}\u003e\n      {items.map(item =\u003e (\n        \u003cdiv key={item.id}\u003e{item.name}\u003c/div\u003e\n      ))}\n      {hasMore \u0026\u0026 \u003cdiv ref={loaderRef}\u003eLoading…\u003c/div\u003e}\n    \u003c/div\u003e\n  );\n}\n```\n\n## License\n\nMIT © [Close](https://github.com/closeio)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloseio%2Fuse-infinite-scroll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloseio%2Fuse-infinite-scroll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloseio%2Fuse-infinite-scroll/lists"}