{"id":23594037,"url":"https://github.com/magicink/use-lazy-loading","last_synced_at":"2025-08-30T08:31:37.689Z","repository":{"id":43212721,"uuid":"205423231","full_name":"magicink/use-lazy-loading","owner":"magicink","description":"A simple React hook for lazy-loading","archived":false,"fork":false,"pushed_at":"2023-01-08T23:38:27.000Z","size":469,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-02-26T08:41:58.123Z","etag":null,"topics":["hooks","lazy-loading","react"],"latest_commit_sha":null,"homepage":null,"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/magicink.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":"2019-08-30T16:55:53.000Z","updated_at":"2022-07-06T12:16:57.000Z","dependencies_parsed_at":"2023-02-08T08:00:27.124Z","dependency_job_id":null,"html_url":"https://github.com/magicink/use-lazy-loading","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicink%2Fuse-lazy-loading","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicink%2Fuse-lazy-loading/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicink%2Fuse-lazy-loading/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicink%2Fuse-lazy-loading/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magicink","download_url":"https://codeload.github.com/magicink/use-lazy-loading/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231461742,"owners_count":18380303,"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":["hooks","lazy-loading","react"],"created_at":"2024-12-27T09:14:48.835Z","updated_at":"2024-12-27T09:14:49.530Z","avatar_url":"https://github.com/magicink.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\n\nA simple, unopinionated React hook for lazy-loading.\n\n**NOTE:** This library uses Interaction Observer API so you will need to use\na polyfill to support older browsers.\n\n### Usage\n\n```js\nimport { useLazyLoading } from 'use-lazy-loading'\n\nconst { lazyLoad } = useLazyLoading(target =\u003e {\n  target.setAttribute('src', target.getAttribute('data-src'))\n  target.classList.add('loaded')\n})\nReact.useEffect(() =\u003e {\n  lazyLoad()\n}, [])\n```\n\n## Initialization\n\n`useLazyLoading(entryCallback, target, config)`\n\n### Arguments\n\n| name            | type       | required | default            | description                                                                                                                                          |\n| --------------- | ---------- | -------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `entryCallback` | `Function` | yes      |                    | A function that is invoked once the target becomes visible. The function should accept the parameter `target` that is the element being operated on. |\n| `target`        | `String`   | no       | `[data-src]`       | The query selector used to find the element that needs to be loaded.                                                                                 |\n| `config`        | `Object`   | no       | `{threshold: 1.0}` | The configurations used to instantiate the intersection observer object.                                                                             |\n\n## API\n\n### Methods\n\n#### `lazyLoad()`\n\nCreates the Intersection Observer and binds the scroll handler.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicink%2Fuse-lazy-loading","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagicink%2Fuse-lazy-loading","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicink%2Fuse-lazy-loading/lists"}