{"id":13450557,"url":"https://github.com/iam-frankqiu/react-use-watch","last_synced_at":"2025-03-23T16:31:35.689Z","repository":{"id":57347230,"uuid":"340378064","full_name":"iam-frankqiu/react-use-watch","owner":"iam-frankqiu","description":":tada: A React hook about triggers once only when dependencies have changed.","archived":false,"fork":false,"pushed_at":"2021-08-19T08:48:05.000Z","size":219,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-02T04:17:42.327Z","etag":null,"topics":["callback","dependency","hooks","react","react-hooks","reactjs","typescript","utilities","watch"],"latest_commit_sha":null,"homepage":"","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/iam-frankqiu.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":"2021-02-19T13:31:18.000Z","updated_at":"2023-03-08T16:38:35.000Z","dependencies_parsed_at":"2022-09-09T12:41:01.471Z","dependency_job_id":null,"html_url":"https://github.com/iam-frankqiu/react-use-watch","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/iam-frankqiu%2Freact-use-watch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iam-frankqiu%2Freact-use-watch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iam-frankqiu%2Freact-use-watch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iam-frankqiu%2Freact-use-watch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iam-frankqiu","download_url":"https://codeload.github.com/iam-frankqiu/react-use-watch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245130805,"owners_count":20565718,"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":["callback","dependency","hooks","react","react-hooks","reactjs","typescript","utilities","watch"],"created_at":"2024-07-31T07:00:36.058Z","updated_at":"2025-03-23T16:31:35.347Z","avatar_url":"https://github.com/iam-frankqiu.png","language":"TypeScript","funding_links":[],"categories":["Packages"],"sub_categories":[],"readme":"# react-use-watch\n![coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)\n![dependency](https://img.shields.io/badge/dependency-zero-brightgreen)\n![npm bundle size](https://img.shields.io/bundlephobia/minzip/react-use-watch)\n![typescript supported](https://img.shields.io/badge/typescript-supported-brightgreen)\n![npm](https://img.shields.io/npm/v/react-use-watch)\n\nA React hook about triggers once only when dependencies have changed.\n\n## Philosophy\n\n```javascript\nuseEffect(() =\u003e {\n  document.title = `You clicked ${count} times`;\n}, [count]); // Only re-run the effect if count changes\n```\nJust like above. The react hooks of [useEffect](https://reactjs.org/docs/hooks-effect.html) will run the effect at least once despite if the count changes or not. It will trigger another time if the count has changed. That's not what we want. What I really want is that only run the effect if the count changes. That's the philosophy of `react-use-watch`.\n\n## Installation\n\nInstall  with npm\n\n```bash\n  npm install react-use-watch\n```\n\nOr with yarn\n\n```bash\n  yarn add react-use-watch\n```\n\n## Usage\n\n```javascript\nimport {useWatch} from \"react-use-watch\";\n\nfunction App() {\n\n  useWatch(() =\u003e {\n    document.title = `You clicked ${count} times`;\n  }, [count]) // Only run the effect if count changes\n\n  return (\u003cspan\u003e\u003c/span\u003e)\n}\n```\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiam-frankqiu%2Freact-use-watch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiam-frankqiu%2Freact-use-watch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiam-frankqiu%2Freact-use-watch/lists"}