{"id":13406551,"url":"https://github.com/Hermanya/use-interval","last_synced_at":"2025-03-14T11:30:31.257Z","repository":{"id":34220117,"uuid":"169025286","full_name":"Hermanya/use-interval","owner":"Hermanya","description":"⏲ Dan Abramov's interval hook.","archived":false,"fork":false,"pushed_at":"2023-03-04T04:11:01.000Z","size":2652,"stargazers_count":67,"open_issues_count":28,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-23T12:15:15.668Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/use-interval","language":"TypeScript","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/Hermanya.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"Hermanya","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-02-04T04:05:04.000Z","updated_at":"2024-07-06T21:02:43.000Z","dependencies_parsed_at":"2024-01-18T23:05:19.674Z","dependency_job_id":"300bde85-d78f-43d6-8aa5-807951b169a4","html_url":"https://github.com/Hermanya/use-interval","commit_stats":{"total_commits":126,"total_committers":11,"mean_commits":"11.454545454545455","dds":0.5079365079365079,"last_synced_commit":"4356e8f195e62ec7b751b64493c6a958cdf28b03"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hermanya%2Fuse-interval","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hermanya%2Fuse-interval/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hermanya%2Fuse-interval/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hermanya%2Fuse-interval/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hermanya","download_url":"https://codeload.github.com/Hermanya/use-interval/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243569023,"owners_count":20312347,"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":[],"created_at":"2024-07-30T19:02:33.376Z","updated_at":"2025-03-14T11:30:30.781Z","avatar_url":"https://github.com/Hermanya.png","language":"TypeScript","funding_links":["https://github.com/sponsors/Hermanya"],"categories":["TypeScript"],"sub_categories":[],"readme":"# use-interval\n\n\u003e React hook for setting an interval as posted on overreacted.io\n\n[![NPM](https://img.shields.io/npm/v/use-interval.svg)](https://www.npmjs.com/package/use-interval) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n[Dan Abramov's blog post explaining why you cannot just use `setInterval` within `useEffect`.](https://overreacted.io/making-setinterval-declarative-with-react-hooks/)\n\n## Used by\n\n\n- [codesandbox / codesandbox-client](https://github.com/codesandbox/codesandbox-client)\n- [kentcdodds / react-performance](https://github.com/kentcdodds/react-performance)\n- [siddharthkp / react-ui](https://github.com/siddharthkp/react-ui)\n- [element-motion](https://github.com/element-motion/element-motion)\n- [wintercounter / mhy](https://github.com/wintercounter/mhy)\n- [sagemathinc / cocalc](https://github.com/sagemathinc/cocalc)\n- [wintercounter / mhy](https://github.com/wintercounter/mhy)\n\n## Install\n\n```bash\nnpm install --save use-interval\n```\n\n## Usage\n\n```tsx\nimport * as React from 'react'\n\nimport useInterval from 'use-interval'\n\nconst Example = () =\u003e {\n  let [count, setCount] = React.useState(0);\n\n  useInterval(() =\u003e {\n    // Your custom logic here\n    setCount(count + 1);\n  }, 1000); // passing null instead of 1000 will cancel the interval if it is already running\n\n  return \u003ch1\u003e{count}\u003c/h1\u003e;\n}\n```\n\n```tsx\n// TypeScript Declaration\nuseInterval(\n  callback: () =\u003e void,\n  delay: number,\n  immediate?: boolean /* called when mounted if true */\n)\n```\n\n## License\n\nMIT\n\n---\n\nThis hook is created using [create-react-hook](https://github.com/hermanya/create-react-hook).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHermanya%2Fuse-interval","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHermanya%2Fuse-interval","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHermanya%2Fuse-interval/lists"}