{"id":15386390,"url":"https://github.com/h-a-n-a/use-immer-state","last_synced_at":"2025-04-19T16:21:34.047Z","repository":{"id":57388125,"uuid":"284101626","full_name":"h-a-n-a/use-immer-state","owner":"h-a-n-a","description":"Use state with reactivity like immer in @reactjs","archived":false,"fork":false,"pushed_at":"2021-07-12T09:20:31.000Z","size":24,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-19T16:25:07.792Z","etag":null,"topics":["hooks","immer","immutable","react","react-hooks","typescript"],"latest_commit_sha":null,"homepage":"","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/h-a-n-a.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":"2020-07-31T18:15:24.000Z","updated_at":"2021-11-02T04:17:35.000Z","dependencies_parsed_at":"2022-08-31T14:34:55.312Z","dependency_job_id":null,"html_url":"https://github.com/h-a-n-a/use-immer-state","commit_stats":null,"previous_names":["h-a-n-a/useimmerstate"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h-a-n-a%2Fuse-immer-state","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h-a-n-a%2Fuse-immer-state/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h-a-n-a%2Fuse-immer-state/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h-a-n-a%2Fuse-immer-state/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/h-a-n-a","download_url":"https://codeload.github.com/h-a-n-a/use-immer-state/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234833680,"owners_count":18893939,"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":["hooks","immer","immutable","react","react-hooks","typescript"],"created_at":"2024-10-01T14:49:07.627Z","updated_at":"2025-01-20T18:19:58.591Z","avatar_url":"https://github.com/h-a-n-a.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# use-immer-state\n\n\u003e 编写对象，由繁入简\n\n## 特性\n- 完整、轻量级实现 Immer 核心\n- React 响应式驱动\n- TypeScript 支持\n\n## 在线体验\n\n[![Edit](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/use-immer-state-demo-wh6dm)\n\n## 安装\n\n```bash\nnpm install use-immer-state --save\n```\n\n## 极速上手\n\n配合 React Hooks 使用：\n\n```tsx\nimport useImmerState from 'use-immer-state'\n\nfunction App() {\n  const [basket, updateBasket] = useImmerState({\n    fruits: ['apple', 'pear']\n  })\n  const addOrange = () =\u003e updateBasket((draft) =\u003e {\n    draft.fruits.push('orange')\n  })\n  return (\n    \u003c\u003e\n      \u003cspan\u003efruits: {String(basket.fruits)}\u003c/span\u003e\n      \u003cbutton onClick={addOrange}\u003eAdd Orange\u003c/button\u003e\n    \u003c/\u003e\n  )\n}\n\nexport default App\n```\n\n还可以只使用 `produce` 函数：\n\n```tsx\nimport { produce } from 'use-immer-state'\n\nconst baseState = {\n  fruits: ['apple', 'pear']\n}\n\nconst result = produce(baseState, (draft) =\u003e {\n  draft.fruits.push('orange')\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh-a-n-a%2Fuse-immer-state","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fh-a-n-a%2Fuse-immer-state","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh-a-n-a%2Fuse-immer-state/lists"}