{"id":26682629,"url":"https://github.com/seonhyungjo/use-delay","last_synced_at":"2025-04-12T13:51:37.137Z","repository":{"id":41724677,"uuid":"236374811","full_name":"SeonHyungJo/use-delay","owner":"SeonHyungJo","description":"⏳Easy Throttle, Debounds Hooks","archived":false,"fork":false,"pushed_at":"2023-01-06T02:28:40.000Z","size":3550,"stargazers_count":3,"open_issues_count":38,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-26T08:34:20.790Z","etag":null,"topics":["debounds","delay","hooks","react","throttle"],"latest_commit_sha":null,"homepage":"https://seonhyungjo.github.io/use-delay/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SeonHyungJo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-26T20:53:24.000Z","updated_at":"2023-03-04T05:11:01.000Z","dependencies_parsed_at":"2023-02-05T03:01:56.070Z","dependency_job_id":null,"html_url":"https://github.com/SeonHyungJo/use-delay","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeonHyungJo%2Fuse-delay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeonHyungJo%2Fuse-delay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeonHyungJo%2Fuse-delay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeonHyungJo%2Fuse-delay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SeonHyungJo","download_url":"https://codeload.github.com/SeonHyungJo/use-delay/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248575741,"owners_count":21127265,"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":["debounds","delay","hooks","react","throttle"],"created_at":"2025-03-26T08:27:41.922Z","updated_at":"2025-04-12T13:51:37.109Z","avatar_url":"https://github.com/SeonHyungJo.png","language":"JavaScript","readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://seonhyungjo.github.io/use-delay/\"\u003e\u003cimg width=\"140\" src=\"./static/use-delay-logo.png\" alt=\"React useDelay Logo\" /\u003e\u003c/a\u003e\n\n\u003ch1 align=\"center\"\u003eReact useDelay Hooks\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![NPM](https://img.shields.io/npm/v/use-delay.svg)](https://www.npmjs.com/package/use-delay) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n\u003cimg width=\"100%\" src=\"./static/use-delay-example.gif\" alt=\"React useDelay example\" /\u003e\n\n\u003c/div\u003e\n\n## Install\n\n```bash\nnpm install --save use-delay\n```\n\n## Usage\n\n```tsx\nimport React, { useCallback, useState } from 'react'\nimport { useThrottle, useDebounds } from 'use-delay'\n\nconst App = () =\u003e {\n  const [throttleCount, setThrottleCount] = useState(0);\n  const [deboundsCount, setDeboundsCount] = useState(0);\n  const actionThrottleHandle = useCallback(() =\u003e {\n    setThrottleCount(throttleCount + 1)\n  })\n\n  const actionDeboundsHandle = useCallback(() =\u003e {\n    setDeboundsCount(deboundsCount + 1)\n  })\n\n  const onTrottle = useThrottle(1000, actionThrottleHandle)\n  const onDebounds = useDebounds(1000, actionDeboundsHandle)\n\n  return (\n    \u003cdiv className={\"outerDiv\"}\u003e\n      \u003cdiv className={\"throttleDiv\"} onScroll={onTrottle}\u003e\n        \u003cdiv className={\"fixcount\"}\u003e\n          {`throttle count ${throttleCount}`}\n        \u003c/div\u003e\n        \u003cdiv className={\"innerDiv\"}\u003e\n          throttle\n        \u003c/div\u003e\n      \u003c/div\u003e\n\n      \u003cdiv className={\"deboundsDiv\"} onScroll={onDebounds}\u003e\n        \u003cdiv className={\"fixcount\"}\u003e\n          {`debounds count ${deboundsCount}`}\n        \u003c/div\u003e\n        \u003cdiv className={\"innerDiv\"}\u003e\n          debounds\n        \u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n  )\n}\nexport default App\n```\n\n\n```css\n\n* {\n box-sizing: border-box;\n}\n\n.outerDiv {\n  display: block;\n  width: 100%;\n  height: 500px;\n  overflow-x: hidden;\n  overflow-y: scroll;\n  border: 1px solid #000\n}\n\n.throttleDiv {\n  display: inline-block;\n  width: 50%;\n  height: 500px;\n  overflow-x: hidden;\n  overflow-y: scroll;\n  border: 1px solid red;\n}\n\n.deboundsDiv {\n  display: inline-block;\n  width: 50%;\n  height: 500px;\n  overflow-x: hidden;\n  overflow-y: scroll;\n  border: 1px solid blue;\n}\n\n.innerDiv {\n  width: 100px;\n  height: 100px;\n  border: 1px solid green;\n\n  margin-top: 1500px;\n}\n\n.fixcount {\n  position: fixed;\n}\n```\n\n## License\n\nMIT © :mouse:[snyung](https://github.com/seonhyungjo)\n\n---\n\nThis hook is created using [create-react-hook](https://github.com/hermanya/create-react-hook).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseonhyungjo%2Fuse-delay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseonhyungjo%2Fuse-delay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseonhyungjo%2Fuse-delay/lists"}