{"id":13672766,"url":"https://github.com/bramblex/react-hooks","last_synced_at":"2025-04-26T21:31:52.246Z","repository":{"id":33398462,"uuid":"158065832","full_name":"bramblex/react-hooks","owner":"bramblex","description":"React Hooks API 在 16.6 上面的模拟实现","archived":false,"fork":false,"pushed_at":"2022-04-04T17:34:10.000Z","size":36,"stargazers_count":96,"open_issues_count":1,"forks_count":15,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T16:05:19.769Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/bramblex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-18T08:58:52.000Z","updated_at":"2023-12-07T06:28:03.000Z","dependencies_parsed_at":"2022-08-07T21:15:13.255Z","dependency_job_id":null,"html_url":"https://github.com/bramblex/react-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/bramblex%2Freact-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramblex%2Freact-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramblex%2Freact-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramblex%2Freact-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bramblex","download_url":"https://codeload.github.com/bramblex/react-hooks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251057444,"owners_count":21529638,"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-08-02T09:01:47.046Z","updated_at":"2025-04-26T21:31:51.987Z","avatar_url":"https://github.com/bramblex.png","language":"TypeScript","readme":"# react-hooks\n\nReact Hooks API 在低版本 React 16.6 下面的一个实现，可以在不升级 React 版本的前提下体验新的 React Hooks API。\n## Install\n\n```\nnpm install blx-react-hooks\n# or\nyarn add blx-react-hooks\n```\n\n## Usage\n在声明函数式组件的时候，通过用 `withHooks()` 函数封装\u001c\u001d就可以就使用 Hooks API 了。与 React 的 Hooks API 只差了需要 `withHooks()` 函数进行封装。\n\n```JSX\nimport {withHooks, useState} from 'blx-react-hooks'\n\n// 如果想在调试的时候看到组件名，定义\bfunction的时候必须要定义成一个命名函数\nconst Counter = withHooks(function Counter({title, initCount}) {\n  const [count, setCount] = useState(initCount)\n  return (\n    \u003cdiv\u003e\n      \u003ch1\u003e{title} \u003c/h1\u003e\n      \u003cbutton onClick={() =\u003e setCount(count - 1)}\u003e - \u003c/button\u003e\n      Count: {count}\n      \u003cbutton onClick={() =\u003e setCount(count + 1)}\u003e + \u003c/button\u003e\n    \u003c/div\u003e\n  )\n})\n```\n\n完整示例 [https://github.com/bramblex/react-hooks/blob/master/example.html](https://github.com/bramblex/react-hooks/blob/master/example.html)\n\n## API\n\n* withHooks\n* useState / useReducer\n* useEffect / useLayoutEffect\n* useContext\n* useRef / useImperativeMethods\n* useMemo / useCallback\n\n\n## Document\nAPI 的文档直接参见 React Hooks API 的文档：[https://reactjs.org/docs/hooks-intro.html](https://reactjs.org/docs/hooks-intro.html)\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbramblex%2Freact-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbramblex%2Freact-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbramblex%2Freact-hooks/lists"}