{"id":15506238,"url":"https://github.com/fi3ework/useprostate","last_synced_at":"2025-11-20T07:02:51.783Z","repository":{"id":57388280,"uuid":"170866070","full_name":"fi3ework/useProState","owner":"fi3ework","description":"🔩Convenient way to play with `useState` hook","archived":false,"fork":false,"pushed_at":"2019-02-15T13:16:18.000Z","size":36,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-19T19:58:26.304Z","etag":null,"topics":[],"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/fi3ework.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":"2019-02-15T13:05:04.000Z","updated_at":"2020-01-15T03:10:57.000Z","dependencies_parsed_at":"2022-09-02T05:51:56.189Z","dependency_job_id":null,"html_url":"https://github.com/fi3ework/useProState","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/fi3ework%2FuseProState","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fi3ework%2FuseProState/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fi3ework%2FuseProState/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fi3ework%2FuseProState/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fi3ework","download_url":"https://codeload.github.com/fi3ework/useProState/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240721851,"owners_count":19847007,"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-10-02T09:26:24.993Z","updated_at":"2025-11-20T07:02:51.756Z","avatar_url":"https://github.com/fi3ework.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# useProState\n\nUse `useState` in a more OOP way.\n\n## Install\n\n```bash\n$ yarn add use-pro-state\n```\n\nor\n\n```bash\n$ npm i use-pro-state\n```\n\n## Usage\n\n### `useProState(obj)`\n\n`useProState` can accept an plain object or array, and return a delegated object or array. Use it as what is passed into `useProState` (it's a ES2015 `Proxy` object).\n\n### `obj.$()`\n\nthe delegated object has a function called `$`, it will directly invoke the set function from `useState`. So use it in the way you use the set function from `useState`\n\n## Example\n\n```jsx\nimport useProState from 'use-pro-state'\n\nconst App = () =\u003e {\n  const david = {\n    name: 'David',\n    pets: {\n      dogs: ['Leo', 'Lucky'],\n      cats: []\n    }\n  }\n  const davidPro = useProState(david)\n\n  return (\n    \u003cdiv\u003e\n      \u003cp\u003e{`${davidPro.name} lives with ${davidPro.pets.dogs.length + davidPro.pets.cats.length} pets`}\u003c/p\u003e\n      \u003cbutton\n        onClick={() =\u003e {\n          davidPro.pets.cats.push('Lisa')\n          davidPro.$()\n        }}\n      \u003e\n        Add a cat\n      \u003c/button\u003e\n    \u003c/div\u003e\n  )\n}\n```\n\n## TODO\n\n- [ ] add test\n- [ ] deal with edge case\n- [ ] Support ES6 `Set` and `Map`\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffi3ework%2Fuseprostate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffi3ework%2Fuseprostate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffi3ework%2Fuseprostate/lists"}