{"id":16896942,"url":"https://github.com/scottrippey/react-use-event-hook","last_synced_at":"2025-04-04T15:08:57.810Z","repository":{"id":38018580,"uuid":"489061002","full_name":"scottrippey/react-use-event-hook","owner":"scottrippey","description":"Same as React's useCallback, but returns a stable reference.","archived":false,"fork":false,"pushed_at":"2023-03-22T05:31:06.000Z","size":188,"stargazers_count":221,"open_issues_count":0,"forks_count":10,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-10-14T17:33:53.185Z","etag":null,"topics":["react","react-memo","usecallback","useevent","useref"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-use-event-hook","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/scottrippey.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}},"created_at":"2022-05-05T17:09:09.000Z","updated_at":"2024-09-12T15:51:04.000Z","dependencies_parsed_at":"2024-06-18T15:32:28.072Z","dependency_job_id":"08ff179c-4a0f-4f30-97f7-37d771ec0cd3","html_url":"https://github.com/scottrippey/react-use-event-hook","commit_stats":{"total_commits":38,"total_committers":4,"mean_commits":9.5,"dds":"0.23684210526315785","last_synced_commit":"7fc8993c3d6a49d3cb9ac8dec1d8f3b189af1802"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scottrippey%2Freact-use-event-hook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scottrippey%2Freact-use-event-hook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scottrippey%2Freact-use-event-hook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scottrippey%2Freact-use-event-hook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scottrippey","download_url":"https://codeload.github.com/scottrippey/react-use-event-hook/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198461,"owners_count":20900080,"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-memo","usecallback","useevent","useref"],"created_at":"2024-10-13T17:34:09.239Z","updated_at":"2025-04-04T15:08:57.787Z","avatar_url":"https://github.com/scottrippey.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-use-event-hook\nSame as React's `useCallback`, but returns a stable reference.\n\nThis library is a user-land implementation of the `useEvent` hook, [proposed in this RFC](https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md).\n\n# Installation\n\n```sh\nnpm install react-use-event-hook\n```\n\n# Usage\n(this example was copied from the RFC)\n\nYou can wrap any event handler into `useEvent`.\n\n```js\nimport useEvent from 'react-use-event-hook';\n\nfunction Chat() {\n  const [text, setText] = useState('');\n\n  const onClick = useEvent(() =\u003e {\n    sendMessage(text);\n  });\n\n  return \u003cSendButton onClick={onClick} /\u003e;\n}\n```\n\nThe code inside `useEvent` “sees” the props/state values at the time of the call. \nThe returned function has a stable identity even if the props/state it references change. \nThere is no dependency array.\n\n# See more\n- [The proposed `useEvent` RFC](https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md)\n- [A hearty discussion on the naming, and edge-case considerations, of this hook](https://github.com/reactjs/rfcs/pull/220)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscottrippey%2Freact-use-event-hook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscottrippey%2Freact-use-event-hook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscottrippey%2Freact-use-event-hook/lists"}