{"id":13846958,"url":"https://github.com/rauldeheer/use-async-effect","last_synced_at":"2026-06-02T08:01:15.596Z","repository":{"id":33522959,"uuid":"159173398","full_name":"rauldeheer/use-async-effect","owner":"rauldeheer","description":":running: Asynchronous side effects, without the nonsense","archived":false,"fork":false,"pushed_at":"2025-08-06T18:43:14.000Z","size":57,"stargazers_count":316,"open_issues_count":2,"forks_count":20,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-09T18:30:15.501Z","etag":null,"topics":["async","async-await","await","hooks","react","react-native","reactjs","use-async-effect","useeffect"],"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/rauldeheer.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-11-26T13:24:08.000Z","updated_at":"2025-07-17T16:50:50.000Z","dependencies_parsed_at":"2025-04-21T07:01:20.710Z","dependency_job_id":"00c06d4f-7a88-4700-a4f4-932ac7abd771","html_url":"https://github.com/rauldeheer/use-async-effect","commit_stats":{"total_commits":61,"total_committers":13,"mean_commits":"4.6923076923076925","dds":0.7540983606557377,"last_synced_commit":"79359810a256cb6aafa09d18beb8264d17719086"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/rauldeheer/use-async-effect","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rauldeheer%2Fuse-async-effect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rauldeheer%2Fuse-async-effect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rauldeheer%2Fuse-async-effect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rauldeheer%2Fuse-async-effect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rauldeheer","download_url":"https://codeload.github.com/rauldeheer/use-async-effect/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rauldeheer%2Fuse-async-effect/sbom","scorecard":{"id":762783,"data":{"date":"2025-08-11","repo":{"name":"github.com/rauldeheer/use-async-effect","commit":"397e4fbc884d502b903eae889f931b319db320f1"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"name":"Code-Review","score":3,"reason":"Found 6/16 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 20 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":3,"reason":"7 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T23:51:52.168Z","repository_id":33522959,"created_at":"2025-08-22T23:51:52.168Z","updated_at":"2025-08-22T23:51:52.168Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33812204,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-02T02:00:07.132Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["async","async-await","await","hooks","react","react-native","reactjs","use-async-effect","useeffect"],"created_at":"2024-08-04T18:00:51.142Z","updated_at":"2026-06-02T08:01:15.578Z","avatar_url":"https://github.com/rauldeheer.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"![Logo](https://raw.githubusercontent.com/rauldeheer/use-async-effect/master/logo.svg?sanitize=true)\n[![npm version](https://badge.fury.io/js/use-async-effect.svg)](https://www.npmjs.com/package/use-async-effect)\n[![license](https://badgen.net/npm/license/use-async-effect)](./LICENSE)\n\n---\n\n:running: Asynchronous side effects, without the nonsense.\n\n```javascript\nuseAsyncEffect(async () =\u003e {\n  await doSomethingAsync();\n});\n```\n\n## Installation\n\n```\nnpm install use-async-effect\n```\nor\n```\nyarn add use-async-effect\n```\n\nThis package ships with TypeScript and Flow types.\n\n## API\n\nThe API is the same as React's `useEffect()`, except for some notable differences:\n\n- The destroy function is passed as an optional second argument:\n\n```javascript\nuseAsyncEffect(callback, dependencies?);\nuseAsyncEffect(callback, onDestroy, dependencies?);\n```\n\n- The async callback will receive a single function to check whether the callback is still mounted:\n\n```javascript\nuseAsyncEffect(async isMounted =\u003e {\n  const data1 = await fn1();\n  if (!isMounted()) return;\n\n  const data2 = await fn2();\n  if (!isMounted()) return;\n\n  doSomething(data1, data2);\n});\n```\n\n\u003e Mounted means that it's running in the current component. It becomes unmounted if the component unmounts, or if the component is re-rendered and the callback is dropped and a new one is called.\n\n## Examples\n\nBasic mount/unmount\n```javascript\nuseAsyncEffect(async () =\u003e console.log('mount'), () =\u003e console.log('unmount'), []);\n```\n\nOmitting destroy\n```javascript\nuseAsyncEffect(async () =\u003e console.log('mount'), []);\n```\n\nHandle effect result in destroy\n```javascript\nuseAsyncEffect(() =\u003e fetch('url'), (result) =\u003e console.log(result));\n```\n\nMaking sure it's still mounted before updating component state\n```javascript\nuseAsyncEffect(async isMounted =\u003e {\n  const data = await fetch(`/users/${id}`).then(res =\u003e res.json());\n  if (!isMounted()) return;\n  setUser(data);\n}, [id]);\n```\n\n## Linting dependencies list using `ESLint`\n\nThe `react-hooks/exhaustive-deps` rule allows you to check your custom hooks. \nFrom the [Advanced Configuration](https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks#advanced-configuration) options:\n\u003e `exhaustive-deps` can be configured to validate dependencies of custom Hooks with the `additionalHooks` option. This option accepts a regex to match the names of custom Hooks that have dependencies.\n\n‼️ Unfortunately, `react-hooks/rules-of-hooks` isn't configurable and the \"Effect callbacks are synchronous to prevent race conditions. Put the async function inside\" warning will be displayed.\n\n```json\n{\n  \"rules\": {\n    // ...\n    \"react-hooks/exhaustive-deps\": [\n      \"warn\",\n      {\n        \"additionalHooks\": \"(useAsyncEffect|useMyOtherCustomHook)\"\n      }\n    ]\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frauldeheer%2Fuse-async-effect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frauldeheer%2Fuse-async-effect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frauldeheer%2Fuse-async-effect/lists"}