{"id":21357127,"url":"https://github.com/tedstoychev/use-reactive-state","last_synced_at":"2025-07-13T00:32:41.174Z","repository":{"id":53229835,"uuid":"194679610","full_name":"todor2810/use-reactive-state","owner":"todor2810","description":"useReactiveState() - a reactive alternative to React's useState()","archived":false,"fork":false,"pushed_at":"2023-01-19T18:30:50.000Z","size":120,"stargazers_count":13,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-29T18:05:47.989Z","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/todor2810.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-07-01T13:37:31.000Z","updated_at":"2023-12-14T16:17:18.000Z","dependencies_parsed_at":"2023-02-11T15:46:02.385Z","dependency_job_id":null,"html_url":"https://github.com/todor2810/use-reactive-state","commit_stats":null,"previous_names":["tedstoychev/use-reactive-state"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/todor2810%2Fuse-reactive-state","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/todor2810%2Fuse-reactive-state/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/todor2810%2Fuse-reactive-state/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/todor2810%2Fuse-reactive-state/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/todor2810","download_url":"https://codeload.github.com/todor2810/use-reactive-state/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225844822,"owners_count":17533161,"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-11-22T05:00:40.343Z","updated_at":"2024-11-22T05:01:12.783Z","avatar_url":"https://github.com/todor2810.png","language":"TypeScript","funding_links":[],"categories":["Packages"],"sub_categories":[],"readme":"`useReactiveState()` - a reactive alternative to React's `useState()`\n\n---\n\n## Installation\n\n```\n$ npm install use-reactive-state\n```\n\n## Example\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003euseState()\u003c/th\u003e\n\u003cth\u003euseReactiveState()\u003c/th\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd valign=\"top\"\u003e\n\n```javascript\nfunction Counter() {\n  const [state, setState] = useState({count: 0});\n\n  return (\n    \u003cdiv\u003e\n      \u003cp\u003eYou clicked {state.count}\u003c/p\u003e\n      \u003cbutton onClick={() =\u003e {\n        setState({\n          ...state,\n          count: state.count + 1\n        });\n      }}\u003e\n        Click me\n      \u003c/button\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\n\u003c/td\u003e\n\u003ctd valign=\"top\"\u003e\n\n```javascript\nfunction Counter() {\n  const state = useReactiveState({count: 0});\n\n  return (\n    \u003cdiv\u003e\n      \u003cp\u003eYou clicked {state.count} times\u003c/p\u003e\n      \u003cbutton onClick={() =\u003e { state.count += 1; }}\u003e\n        Click me\n      \u003c/button\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n## Limitation of `useReactiveState()`\n\n- `state` cannot be destructured:\n\n```javascript\n// This won't work\nconst {count} = useReactiveState({count: 0});\n```\n\n```javascript\n// This will work\nconst state = useReactiveState({count: 0});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftedstoychev%2Fuse-reactive-state","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftedstoychev%2Fuse-reactive-state","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftedstoychev%2Fuse-reactive-state/lists"}