{"id":22269105,"url":"https://github.com/jason89521/hooks","last_synced_at":"2026-05-02T14:39:44.267Z","repository":{"id":57170114,"uuid":"455014911","full_name":"jason89521/hooks","owner":"jason89521","description":"Some common used react hooks","archived":false,"fork":false,"pushed_at":"2022-02-07T11:36:43.000Z","size":121,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-03T10:40:23.201Z","etag":null,"topics":["react","react-hooks"],"latest_commit_sha":null,"homepage":"","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/jason89521.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-03T03:16:31.000Z","updated_at":"2023-03-07T04:36:24.000Z","dependencies_parsed_at":"2022-08-27T12:01:52.736Z","dependency_job_id":null,"html_url":"https://github.com/jason89521/hooks","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/jason89521%2Fhooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jason89521%2Fhooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jason89521%2Fhooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jason89521%2Fhooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jason89521","download_url":"https://codeload.github.com/jason89521/hooks/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245486365,"owners_count":20623244,"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":["react","react-hooks"],"created_at":"2024-12-03T11:15:08.210Z","updated_at":"2026-05-02T14:39:44.233Z","avatar_url":"https://github.com/jason89521.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hooks\n\n[![Npm package version](https://badgen.net/npm/v/@yuxuan-zheng/hooks)](https://npmjs.com/package/@yuxuan-zheng/hooks)\n\nSome common used hooks.\n\n## API Reference\n\nAll hooks will return either a value or an array. If the return value is an array, this document will list the values in order.\n\n- [useDebounced](#usedebounced)\n- [useIntersection](#useIntersection)\n\n### `useDebounced`\n\n#### Description\n\nUse this hook to get the debounced value.\n\n#### Parameters\n\n| Name       | Type     | Default value | Description                                 |\n| :--------- | :------- | :------------ | :------------------------------------------ |\n| `value`    | `T`      | `undefined`   | **Required** The value you want to debounce |\n| `interval` | `number` | `1000`        | The debounce interval in milliseconds       |\n\n#### Returns\n\n| Name             | Type | Description         |\n| :--------------- | :--- | :------------------ |\n| `debouncedValue` | `T`  | The debounced value |\n\n#### Example\n\n```js\nconst Example = () =\u003e {\n  const [value, setValue] = useState('');\n  const debouncedValue = useDebounced(value);\n\n  const onChange = e =\u003e setValue(e.target.value);\n\n  useEffect(() =\u003e {\n    // Do whatever you want upon the debounced value change\n    console.log(debouncedValue);\n  }, [debouncedValue]);\n\n  return \u003cinput type=\"text\" value={value} onChange={onChange} /\u003e;\n};\n```\n\n### `useIntersection`\n\n#### Description\n\nUse this hook to determine whether the element is displayed in viewport.\n\n#### Parameters\n\nThis hook doesn't need parameters.\n\n#### Returns\n\n| Name             | Type                            | Description                                                                           |\n| :--------------- | :------------------------------ | :------------------------------------------------------------------------------------ |\n| `isIntersecting` | `boolean`                       | Use this value to determine whether the target element is intersecting with viewport. |\n| `callbackRef`    | `(element:HTMLElement) =\u003e void` | Pass this callback to the target element's ref.                                       |\n\n#### Example\n\n```js\nconst Example = () =\u003e {\n  const [isIntersecting, callbackRef] = useIntersection();\n\n  useEffect(() =\u003e {\n    // Do whatever you want when the target is intersecting with viewport\n  }, [isIntersecting])\n\n  return \u003cdiv ref={callbackRef}\u003e\u003c/div\u003e\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjason89521%2Fhooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjason89521%2Fhooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjason89521%2Fhooks/lists"}